Python MCQ and Answers – Part 4
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer.
1. Which of the following keywords is a placeholder for the body of a function?
A break
B continue
C body
D pass
2. Suppose we have a = [1,2,3,4,5]
, which of the following statements is correct?
A print(a[:100]) #Print [1,2,3,4,5] ?
B print(a[:]) #Print [1,2,3,4] ?
C print(a[0:]) #Print [2,3,4,5] ?
D print(a[-1:]) #Print [1,2] ?
3. What is the output of the following code?
def getLen(): d = {} d["python"] = 22 d["java"] = 27 d["php"] = 53 d["c"] = 87 return len(d) print(getLen())
A 3
B 8
C 5
D 4
4. Who created the Python language?
A Denis Ritchie
B Guido Van Rossum
C James Gosling
D Tom Cruise
5. Can the “return” statement in Python return multiple values?
A Yes
B No
6. What is the purpose of the following code?
if __name__ == "__main__": myFunction()
A Create a new module
B Run the python module as the main program
C Create new objects
D Defines a generator
7. In python, we use “try” and “catch” for exception handling?
A Yes
B No
6. Which module is used in python to create graphics?
A Graphics
B Turtle
C Canvas
D Tkinter
7. Which of the following code, link a canvas with a key event ‘p’
A Canvas.entered(Enter, p)
B Canvas.bind(key, p)
C Canvas.bind('<key>', p)
D Canvas.entered('<enter>', p)
8. Which of the following statements is true?
A Python is a high level programming language.
B Python is an interpreted language.
C Python is an object oriented language.
D All the answers are true
9. What is the output of the following code: print 9//2
A 4
B 4.5
C 4.0
D Error
10. Which function overloads the operator >> ?
A move()
B gt()
C more()
D None of the above