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

Answer : D


The method join() takes list of string as input and returns string as output. It removes ‘,’ and add the given string with join to the list.

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 - What is output of following code −


A - ('hijk', 'cd', ' ')

B - ('hijk')

C - ('hijk', ' ', ' ')

D - Name error

Answer : C


Since there are no separators in the given string so the output is the same string.

Q 4 - What is output for − min(''hello world'')

A - e

B - a blank space character

C - w

D - None of the above.

Answer : B


python considers a blank space character as minimum value in a string.

Q 5 - What is output of following −


A - ‘any’

B - ‘yan’

C - b’any’

D - x’any’

Answer : C


encode() returns bytes object.

Q 6 - Analyze the given below code?

class Demo: 
   def __init__(self,d): 
   def print(self): 
a = Demo(''Hello'') 

A - You cannot use print(self) as a function name.

B - Program has an error because class A does not have a constructor.

C - Program will print ‘Hello’ if we change print(d) to print(self.d).

D - Syntax Error.

Answer : C


D stores the argument value here. Thus when we call the class ‘‘Hello’’ is passed as an argument which is stored in the variable d.

Answer : B, C, D.


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

Q 8 - Which function can be used on the file to display a dialog for saving a file?

A - Filename = savefilename()

B - Filename = asksavefilename()

C - Fielname = asksaveasfilename()

D - No such option in python.

Answer : C


This is the default method to display a dialog for saving a file in Tkinter module of Python.

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 is the value of a, b, c in the given below code?

a, b = c = 2 + 2, ''TutorialsPoint''

A - a=4, 'TutorialsPoint'

b= 4, 'TutorialsPoint'

c= 4, 'TutorialsPoint'

B - a=2

b= 'TutorialsPoint'

c=4, 'TutorialsPoint'

C - a=4

b= 'TutorialsPoint'

c=4, 'TutorialsPoint'

D - a=4

b= 'TutorialsPoint'

c= NULL.

Answer : C