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 of −

33 == 33.0

A - False

B - True

C - 33

D - None of the above

Answer : B


comparison operator evaluates true and false. And in python we need not specify whether the number is int or float.

Q 2 - What is output of following code −

x = 2
y = 10
x * = y * x + 1

A - 42

B - 41

C - 40

D - 39

Answer : A


x * = y * x + 1 means x = x * (y * x + 1)

Q 3 - Pylab is a package that combine _______,________&______ into a single namespace.

A - Numpy, scipy & matplotlib

B - Numpy, matplotlib & pandas

C - Numpy, pandas & matplotlib

D - Numpy, scipy & pandas

Answer : A


pylab package in python combines numpy, scipy & matplotlib into a single namespace.

Q 4 - How can we check whether the object is instance of class or not. Let us consider an object O which is instance of class B.

A - B.isinstance(O)

B - O.isinstance(B)

C - isinstance(O,B)

D - isinstance(B,O)

Answer : C


isinstance() method is used to find whether the object is instance of class or not.

Q 5 - What is the output of the code?

def f():
   global z
   print('z is: ', z)
   print('new value of global z is: ', z)

   print('Value of z is: ', z)

A - z is 100

new value of global z is: 100

value of z is 100

B - z is 100

new value of global z is: 100

value of z is 50

C - z is 100

new value of global z is: 50

value of z is 100

D - z is 100

new value of global z is: 50

value of z is 50

Answer : D


Here in the above code ‘global’ keyword is used to state that ‘z’ is global variable. So when we assign a value to z in the function then the new assigned value is reflected whenever we use the value of ‘z’ in the main block or outside the function.

Q 6 - What is the output of the following code?

class P: 
   def __init__(self): 
   def print(self): 
      print(self.__x, self.y)  
class C(P): 
   def __init__(self): 
d = C() 

A - 300 400

B - 100 400

C - 100 200

D - 300 200

Answer : B


In the above code x is a private variable declared in the class P. Thus value of x cannot be changed in the class C which inherits class P. But y is not a private variable thus its value can be changed.

Answer : C


+ Operator cannot be operated on the sets.

Q 8 - Select the correct function among them which can be used to write the data to perform for a binary output?

A - Write

B - Output.binary

C - Dump

D - Binary.output

Answer : C

Q 9 - Which way among them is used to create an event loop ?

A - Window.eventloop()

B - Window.mainloop()

C - Window.loop()

D - Eventloop.window()

Answer : B