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 −

'search'. find('S') ?

A - s

B - -1

C -

D - None of the above

Answer : B

Explanation

The method find() is case sensitive.

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

A - regex

B - re

C - pyre

D - pyregex

Answer : B

Explanation

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

We can import re module as − import re.

Q 3 - In the following options which are python libraries which are used for data analysis and scientific computations

A - Numpy

B - Scipy

C - Pandas

D - All the above

Answer : D

Explanation

Numpy,Scipy,pandas are few libraries in python which are used for data analysis and scientific computations.

Q 4 - What is output for − max(''please help '')

A - s

B - a blank space character

C - e

D - p

Answer : A

Explanation

python considers z as maximum value in the string and a blank space character as minimum value. So it goes like blank space, a to z as minimum to maximum.

Q 5 - What is output of following −

print(''abbzxyzxzxabb''.count(abb',-10,-1))

A - 2

B - 0

C - 1

D - Error

Answer : B

Explanation

It Counts the number of times the substring abb' is present starting from position 2 and ending at position 11 in the given string.

Q 6 - Guess the output −

def main(): 
   try: 
      func() 
      print(''print this after function call'') 
   except ZeroDivisionError: 
      print('Divided By Zero! Not Possible! ') 
   except: 
      print('Its an Exception!') 
def func(): 
   print(1/0) 
main()

A - Its an Exception!'

B - Divided By Zero! Not possible!'

C - print this after function call' followed by Divided By Zero! Not Possible!'

D - print this after function call' followed by Its an Exception!'

Answer : B

Explanation

The function func' will not run because it contains an exception. So in try and expect block. The function called under try will not run and will move to except block which defines the type of exception present in the function func'. Thus block of statements present in except ZeroDivisionError is printed.

Q 7 - Which among them will produce {'a', 'b', 'c'}?

A - Tuple(''abc'')

B - List(''abc'')

C - Set(''abac'')

D - None of the above.

Answer : D

Explanation

Set does not allow the repetitive values in it and it separated each value present under a string.

Q 8 - Which among them is incorrect for set s={100,101,102,103}

A - Len(s)

B - Sum(s)

C - Print(s[3])

D - Max(s)

Answer : C

Explanation

There is no indexing in Sets.

Answer : B

Explanation

Text is created in the canvas by using create_text method of canvas. Color of the text can be set according to the user which is specified under filled'.

Q 10 - Which is the special symbol used in python to add comments?

A - $

B - //

C - /*.... */

D - #

Answer : D

python_questions_answers.htm
Advertisements