Python Online Quiz


Following quiz provides Multiple Choice Questions (MCQs) related to Python. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - What is output for −

raining'. find('z') ?

A - Type error

B - ' '

C - -1

D - Not found

Answer : C


If the string is not found by method find() , it returns the integer -1.

Q 2 - Name the python module which supports regular expressions.

A - regex

B - re

C - pyre

D - pyregex

Answer : B


re is the module which supports regular expressions and is part of standard library.

We can import re module as − import re.

Q 3 - Select the option for following code −

s = 0
for d in range(0, 5, 0.1):
… s += d
… print(s)

A - Syntax Error

B - Type Error

C - Runtime Error

D - Both b & c

Answer : D


we will get type error during runtime as float object cannot be interpreted as integer. Here 0.1 is the float value.

Answer : B


If A is proper subset of B then hen all elements of A are in B but B contains at least one element that is not in B.

Q 5 - What will be the output of the following code?

def total(initial = 5, *num, **key):
   count = initial
   for n in num:
   for k in key:
   return count
print(total(100,2,3, clouds=50, stars=100))

A - 260

B - 160

C - 155

D - 255

Answer : D


It takes initial value as 100 now. And adds 2, 3, 50 and 100 to it as according to code.

Q 6 - What is the output of the code?

   list = 5*[0]+5*[10] 
   x = list[9] 
except IndexError: 
   print(''Index out of Bond! '') 
   print(''Nothing is wrong!'') 
   print(''Finally block!'') 

A - ‘Finally Block!’

B - ‘Done!’ follow by ‘Nothing is wrong!’

C - ‘Nothing is wrong!’ followed by ‘Finally block!’

D - ‘Done!’ follow by ‘Nothing is wrong!’ followed by ‘Finally block’.

Answer : D


In the above Try block we make a list of total 10 elements by adding 5 times zero and 5 times 10. Thus when we try to find out the element at index 9 no error is raised by Python.

Answer : B, C, D.


Recursive function is used to make the code simpler. They are better version of non-recursive functions.

Answer : B


Checkbutton method is used to make a checkbox. In the parameters we need to pass the values as asked in the question. Here it should bind to v1 thus variable is set to v1 and frame should be under frame1 thus frame1 mentioned in the code.

Q 9 - In Python we can create a popup menu. Select the code to display a popup menu?

A -,250)

B -

C - Menu.display()

D - Menu.display_popup(250,250)

Answer : A

Q 10 - What will be the output of the following code?


A - <class 'float'>

B - <class 'int'>

C - NameError: ‘½’ is not defined.

D - 0.5

Answer : A


Output of ½ is 0.5.