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 - Which of the following data types is not supported in python?

A - Tuple

B - Dictionary

C - Generics

D - List

Answer : C


Generics is not a supported data type.

Q 2 - What is the output of print str[0] if str = 'Hello World!'?

A - Hello World!

B - H

C - ello World!

D - None of the above.

Answer : B


H is the correct answer.

Q 3 - What is the output of print tuple[1:3] if tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )?

A - ( 'abcd', 786 , 2.23, 'john', 70.2 )

B - abcd

C - (786, 2.23)

D - None of the above.

Answer : C


It will print elements starting from 2nd till 3rd. Output would be (786, 2.23).

Q 4 - Which of the following function convert an object to a string in python?

A - int(x [,base])

B - long(x [,base] )

C - float(x)

D - str(x)

Answer : D


str(x) − Converts object x to a string representation.

Q 5 - Which of the following operator in python performs exponential (power) calculation on operands?

A - **

B - //

C - is

D - not in

Answer : A


** Exponent − Performs exponential (power) calculation on operands. a**b = 10 to the power 20 if a = 10 and b = 20.

Q 6 - Which of the following function returns a random item from a list, tuple, or string?

A - choice(seq)

B - randrange ([start,] stop [,step])

C - random()

D - seed([x])

Answer : A


choice(seq) − Returns a random item from a list, tuple, or string.

Q 7 - Which of the following function checks in a string that all characters are alphanumeric?

A - shuffle(lst)

B - capitalize()

C - isalnum()

D - isdigit()

Answer : C


isalnum() − Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise.

Q 8 - Which of the following function replaces all occurrences of old substring in string with new string?

A - replace(old, new [, max])

B - strip([chars])

C - swapcase()

D - title()

Answer : A


replace(old, new [, max]) − Replaces all occurrences of old in string with new or at most max occurrences if max given.

Answer : A


['Hi!', 'Hi!', 'Hi!', 'Hi!']

Q 10 - What is the following function reverses objects of list in place?

A - list.reverse()

B - list.sort([func])

C - list.pop(obj=list[-1])

D - list.remove(obj)

Answer : A


list.reverse() − Reverses objects of list in place.