Python MCQ and Answers – Part 9
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer.
1. Which of the following is not a keyword in Python?
A eval
B assert
C nonlocal
D pass
2. All keywords in Python are ______
A uppercase
B lowercase
C capitalized
D None of the above
3. What is the output of the following code?
def sayHello(*name): print('Hello', name) sayHello('Yohan', 'Thomas')
A Hello Yohan Hello Thomas
B Hello (‘Yohan’, ‘Thomas’)
C Hello Yohan
D Syntax error! sayHello() can only take one argument.
4. Which of the following statements is used to create an empty set?
A { }
B ( )
C [ ]
D set()
5. What is a recursive function?
A A function that calls all the functions of the program.
B A function that calls itself.
C A function that calls all the functions of the program except itself.
D There is no recursive function in Python.
6. What is the output of the following code?
res = lambda x: x * x print(res(5))
A 5
B res(5)
C 25
D None
7. Which of the following cannot be declared as a variable?
A __init__
B in
C it
D on
8. What is the output of the following code when executed in Python shell?
>>> d = {1,2,3} >>> d.intersection_update({2,3,4,5}) >>> d
A {2,3}
B {1,4,5}
C Error, duplicate element in the list
D Error, no method called intersection_update
9. What is the output of the following code?
l = ['ab', 'cd'] for i in l: i.upper() print(l)
A [‘AB’, ‘CD’]
B [‘ab’, ‘cd’]
C [None, None]
D None of the above
10. What is the output of the following code?
True = False while True: print(True) break
A False
B True
C None
D None of the above