Python MCQ and Answers – Part 5
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer.
1. Which operator is overloaded by the or() function?
A //
B /
C ||
D |
2. To define a code block in Python, we use _____?
A Braces
B Indentation
C Parenthesis
D Double quote
3. What is the output of the following program?
i = 0 while i < 3: print i i++ print i+1
A 0 2 1 3 2 4
B 1 0 2 4 3 5
C 0 1 2 3 4 5
D Error
4. Which of the following statements is correct?
A The variable name can begin with an underscore “_”.
B The variable name can start with a number.
C Keywords cannot be used as a variable name.
D The variable name can have symbols like: @, #, $ etc.
5. What is the output of the following program?
print "Welcome to StackHowTo"[::-1]
A oTwoHkcatS ot emocleW
B Welcome to StackHowTo
C o
D Error
6. In the following code n = '2'
, n is a(n) _______?:
A char
B integer
C string
D tupl
7. Given a function that returns no value, what value is displayed when it is executed on the shell?
A bool
B int
C void
D None
8. What is the output of the following program?
print(1, 2, 3, 4, sep='*')
A 1 2 3 4
B 1*2*3*4
C 1234
D 24
9. Which Python module supports regular expressions?
A pyregex
B regex
C re
D None of the above
10. To get user input in Python, we use _______?
A <>
B input()
C scanf()
D cin