0% found this document useful (0 votes)
11 views

Python Test

The document contains a collection of practical and theory questions related to Python programming. It includes questions about printing strings and lists, list operations, string slicing and formatting, functions, data types like tuples and dictionaries, modules and libraries.

Uploaded by

arkayinterview
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Python Test

The document contains a collection of practical and theory questions related to Python programming. It includes questions about printing strings and lists, list operations, string slicing and formatting, functions, data types like tuples and dictionaries, modules and libraries.

Uploaded by

arkayinterview
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 3

# Practical Questions:

1. String = "Hello Hi Python"


Print the given string as group of 3 separate strings.

2. fruits = ["grape", "apple", "mango"]


Print all the items in the given list using for loop.

3. List1 = [1, 2, 3]
list2 = [2, 4]

append list2 in list1.

4. what will be the output of the given code?

b = [1, 3, 4, 6, 7, 10]

st = "Python tutorial"
sliceportion = slice(0, 4)
print(b[sliceportion])
print(st[sliceportion])

5. What will be the output of the given code?

str = " Python tutorial"

str = str.strip(" P")


print(str)

6. What will be the output of the following code?

a = ["Python", "tutorial", "and", "test"]

a = " ".join(a)
print(a)

7. Replace “_” from all the items in the list with “-” and print
the list.

columns = ["First_name", "Middle_name", "Last_name"]

8. What will be the output of the following code?

myStr = "I am writing a Python program"


x = len(myStr)
print(x)

9. What will be the output of the following code?

bikes = ['trek', 'redline', 'giant']


ans='trek' in bikes
print(ans)

10. Sort the given list in ascending order.

A = [3, 2, 1]

11.What will be the output of the following code?

products = ['table', 'chair', 'sofa', 'bed', 'lamp']

prices = [50, 20, 200, 150, 10]

for product, price in zip(products, prices):

print('Product: {}, Price: {}'.format(product, price))

12.What will be the output of the following code?

numbers = [1, 2, 3, 4, 5, 6]
list(filter(lambda x: x % 2, numbers))

13. What will be the output of the following code?

cities = ('Madrid', 'Valencia', 'Barcelona', 'Munich',


'Stuttgart')
tuple(filter(lambda x: x.startswith(('M', 'V')), cities))

14. What will be the output of the following code?


import datetime as dt
now = dt.date.today()
print(now.year)
print(now.month)

15. What will be the output of the following code?

def division(num1, num2=2):

print(num1/num2)

division(16,4)
division(16)

# Theory Questions

1. What type of language is python? Programming or scripting?

2. What is pep 8?
3. What are decorators in Python?
4. What is the difference between .py and .pyc files?
5. Is python case sensitive?

6. Is indentation required in python?

7. What is the difference between Python Arrays and lists?

8. What is __init__?

9. What is a lambda function?

10. What is self in Python?

11. What does [::-1} do?

12. How do you write comments in python?

13. How to comment multiple lines in python?

14. What are docstrings in Python?

15. What does this mean: *args, **kwargs? And why would we use it?

16. What are Python libraries? Name a few of them.

17. What is split used for?


18. How to import modules in python?

19. What are unit tests in Python?


20. How to use map(), filter() and reduce() functions in python?

You might also like