Python MCQ and Answers – Part 8
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer.
1. If a class is derived from two different classes, this is called ______?
A Multilevel inheritance
B Multiple inheritance
C Hierarchical inheritance
D Python inheritance
2. What is the output of the following code?
x = True y = False z = False if x or y and z: print "STACKHOWTO" else: print "stackhowto"
A STACKHOWTO
B stackhowto
C The code does not display anything
D None of the above
3. What is the output of this expression, 3*1**3?
A 1
B 3
C 9
D 27
4. Is Python case sensitive?
A Yes
B No
C Depends on System
D None of the above
5. What is the output of the following code?
x = True y = False z = False if not x or y: print 10 elif not x or not y and z: print 20 elif not x or y or not y and z: print 30 else: print 40
A 10
B 20
C 30
D 40
6. Which of the following statements is true?
A In Python, the same operator can behave differently depending on the operands.
B You can change the behavior of operators in Python.
C The special __add__() method is called when the + operator is used.
D All the answers are true
7. Which of the following statements is invalid?
A _x = 1
B __x = 1
C __str__ = 1
D All the answers are true
8. What is the output of the following code?
count = 1 def calculate(): global count for i in (1, 2, 3, 4): count += 1 calculate() print count
A 1
B 4
C 5
D None of the above
9. Which of the following instructions will work without error?
A round(2.5)
B round(999.214,3,0)
C round()
D round(102.4879,1,7)
10. If the “return” instruction is not used in a function, this one will return:
A 0
B “None” object
C Random value
D Error