Python MCQ and Answers – Part 6
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer.
1. What is the output of the following code?
nbrs = [1, 2, 3] print(nbrs)
A 1, 2, 3
B 1 2 3
C [1, 2, 3]
D [1 2 3]
2. What is the output of the following code?
print 0.1 + 0.2 == 0.3
A False
B True
C Depends on System
D Error
3. What is the output of the following code?
print(5 >= 5)
A 5 >= 5
B True
C False
D None
4. Which one is not a complex number?
A z = 1 + 2j
B z = 1 + 2l
C z = 1 + 2J
D z = complex(1, 2)
5. An instruction using the “AND” operator returns “true” if _______
A Both operands are “true”
B Both operands are “false”
C One of the operands is “true”
D The first operand is “true”
6. Which of the following statements is correct about Python?
A It automatically takes care of the garbage collector.
B It can be easily integrated with C, C ++, COM, ActiveX, CORBA and Java.
C Both A and B are true.
D All the answers are true
7. Based on the following code, which of the following statements is true?
def sayHello(): print("Hello") str = sayHello()
A sayHello() is a function, str is a variable. The two are not objects.
B sayHello() and str refer to the same object.
C sayHello() and str refer to different objects.
D Syntax error! You cannot assign a function to a variable in Python.
8. What is the output of the following code?
def fun1(): global x x = 20 def fun2(): global x x = 30 print('x =', x) x = 10 fun1() print('x =', x)
A x = 10
B x = 20
C x = 30
D x = 10 x = 30
9. Which of these data types is not a basic type in Python?
A Lists
B Class
C Dictionary
D Tuples
10. Which of the following statements is true?
A An object is constructed from a class
B You can only create one object from a given class.
C Both A and B are true.
D All the answers are true