Top 50+ Solved Python Programming MCQ Questions Answer
Q. What is the output of the following program :i = 0while i < 3: print i print i+1
a. 0 2 1 3 2 4
b. 0 1 2 3 4 5
c. 0 1 1 2 2 3
d. 1 0 2 4 3 5
Q. Which module in Python supports regular expressions?
a. re
b. regex
c. pyregex
d. None of the above
Q. What is the output of the following program :def myfunc(a): a = a + 2 a = a * 2 return aprint myfunc(2)
a. 8
b. 16
c. Indentation Error
d. Runtime Error
Q. What is the output of the following program :print '{0:.2}'.format(1.0 / 3)
a. 0.333333
b. 0.33
c. 0.333333:-2
d. Error
Q. What is the output of the following program :print '{0:-2%}'.format(1.0 / 3)
a. 0.33
b. 0.33%
c. 33.33%
d. 33%
Q. What is the output of the following program :i = 0 while i < 3: print i i += 1 else: print 0
a. 0 1 2 3 0
b. 0 1 2 0
c. 0 1 2
d. Error
Q. What is the output of the following program :i = 0while i < 5: print(i) i += 1 if i == 3: breakelse: print(0)
a. 0 1 2 0
b. 0 1 2
c. Error
d. None of the above
Q. What is the output of the following program :print 'abcefd'.replace('cd', '12')
a. ab1ef2
b. abcefd
c. ab1efd
d. ab12ed2
Q. What is the output of the following program?dictionary1 = {'GFG' : 1, 'Google' : 2, 'GFG' : 3 }print(dictionary1['GFG']);
a. Compilation error due to duplicate keys
b. Runtime time error due to duplicate keys
c. 3
d. 1