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 −

' ' in 'python' ?

A - 'python'

B - False

C - Name error

D - True

Answer : D


To strings connected by ‘in’ operator gives true and false.

Q 2 - How can we swap two numbers a = 10, b = 20 in python without using third variable?

A - a = b

b = a

B - a,b = b,a

C - both a & b

D - b = a

a = b

Answer : C


To swap two numbers we can use both a & b option. Both a & b are similar statemnts written in different ways.

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.

Q 4 - What is output of following code −

def func(x, ans):
      return 0
      return func(x-1, x+ans) 

A - 0

B - 1

C - 2

D - 3

Answer : A

Q 5 - What command is used to shuffle a list ‘L’?

A - L.shuffle()

B - random.shufflelist(L)

C - shuffle(L)

D - random.Shuffle(L)

Answer : D


To shuffle the list we use random.shuffle(List_name) function.

Answer : B


x is the object created by the constructor of the class Circle().

Q 7 - Suppose you are given a set(s1={1,2,3}) then what is the output for the code −

2 * s1?

A - (1,1,2,2,3,3)

B - [1,1,2,2,3,3]

C - Illegal

D - (1,2,3,1,2,3)

Answer : C


* cannot be operated on the sets.

Answer : D


You need to define the format in which you want to open the file. Proper path has to be declared by the user for the interpreter to reach the destination of the file.

Q 9 - Suppose you are using a grid manager then which option is best suitable to place a component in multiple rows and columns?

A - Columnspan and rowspan

B - Only row

C - Only column

D - Only rowspan

Answer : A

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

minidict = { 'name': 'TutorialsPoint', 'name': 'website'}

A - TutorialsPoint

B - Website

C - ('TutorialsPoint' , 'website')

D - It will show an Error.

Answer : B


Dictionary gets updated by the above code as the key has been assigned a new value.