Common Jobs
Python Quiz
1 / 38
1. What is the output of below python code?
def say(message, times=1):
print(message*times)
say('Hello')
say('World',5)
2 / 38
2. What will be output for the following code?
import numpy as np
a=np.array([1,2,1,5,8])
b=np.array([0,1,5,4,2])
c=a+b
c=c*a
print(c[2])
3 / 38
3. Which of the following is used to define a block of code in Python language?
4 / 38
4. The variable which is defined outside the function is called
5 / 38
5. What will be the output of this statement?
i = 0
while i < 5:
print(i)
i += 1
if i == 3:
break
else:
print(0)
6 / 38
6. Which one of the following syntaxes is the correct syntax to read from a simple text file stored in ''d:\java.txt''?
7 / 38
7. Which of the following is not the built-in function?
8 / 38
8. The keyword we used to define a function is
9 / 38
9. Amongst which of the following is / are needed to open an existing file?
10 / 38
10. Which of these definitions correctly describes a module?
11 / 38
11. What is the output of print(math.pow(3, 2))?
12 / 38
12. Which keyword is used for conditional statements in Python?
13 / 38
13. Which of the following is a valid Python comment?
14 / 38
14. Amongst which of the following is / are the conditional statement in Python code?
15 / 38
15. Which of the following function is used to convert list items into string?
16 / 38
16. Which exception is raised when dividing by zero in Python?
17 / 38
17. What is the output of the following Python code?
import array
a = array.array('i', [1, 2, 3])
del a[1]
print(a)
18 / 38
18. What is the output of 5 // 2?
19 / 38
19. Which operator is used for floor division?
20 / 38
20. What will be the output of the following Python code?
x=13
if x>12 or x<15 and x==16:
print("Given condition matched")
print("Given condition did not match")
21 / 38
21. What is the output of below code?
print(2**3 + (2+ 6)**(1 + 1))
22 / 38
22. Which of the following is the correct way to define a tuple in Python?
23 / 38
23. Python Dictionary is used to store the data in
24 / 38
24. What is the correct way to access the last element of a list in Python?
25 / 38
25. What will be the output of the following Python code?
def show(id,name):
print("Your id is :",id,"and your name is :",name)
show(12,"deepak")
26 / 38
26. Which one of the following is the correct way of calling a function
27 / 38
27. How does Python's garbage collection work?
28 / 38
28. Amongst which of the following is / are the conditional statement in Python code?
29 / 38
29. Amongst which of the following is / are true about the while loop?
30 / 38
30. What is the output of the following code? my_list = [1, 2, 3, 4, 5] print(len(my_list))
31 / 38
31. What is the correct way to convert a string to lowercase in Python?
32 / 38
32. Which Python module is used to parse dates in almost any string format?
33 / 38
33. Which function opens a file for reading in Python?
34 / 38
34. Which is NOT true about recursion?
35 / 38
35. What does the with statement in Python do?
36 / 38
36. What is output of following code
x = 2
y = 10
x * = y * x + 1
37 / 38
37. Which keyword is used to exit from a loop in Python?
38 / 38
38. Which of the following is a valid variable name in Python?
Your score is
The average score is 48%
Restart quiz