Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

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 −

a = ['hat', 'mat', 'rat']

'rhyme'.join(a)

A - [hat','mat','rat','rhyme']

B - hatmatratrhyme'

C - [hat mat rat rhyme']

D - hatrhymematrhyme rat'

Answer : D

Explanation

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

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 − min(''hello world'')

A - e

B - a blank space character

C - w

D - None of the above.

Answer : B

Explanation

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

Q 5 - Find the output of the code?

def f(a, b = 1, c = 2):
   print('a is: ',a, 'b is: ', b, 'c is: ', c)
f(2, c = 2)
f(c = 100, a = 110)

A - a is: 2 b is: 1 c is: 2

a is: 110 b is: 1 c is: 100

B - a is: 2 b is: 2 c is: 2

a is: 110 b is: 2 c is: 100

C - a is: 0 b is: 2 c is: 2

a is: 110 b is: 0 c is: 100

D - a is: 110 b is: 0 c is: 100

a is: 110 b is: 0 c is: 100

Answer : A

Explanation

Value of Arguments is passed to the parameters in order of their sequence.

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

eval(''1 + 3 * 2'')

A - 1+6'

B - 4*2'

C - 1+3*2'

D - 7

Answer : D

Explanation

Eval is a method used to evaluate the values entered in the braces.

Answer : B, C, D.

Explanation

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

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 - Select the correct option to draw a rectangle centred at 50,50 with width and height as 50, 70 respectively.

A - Canvas.create_rect(50,50,50,70)

B - Canvas.create_rect(50,70,50,50)

C - Canvas.create_rectangle(50,50,50,70)

D - Tkinter.create_rect(50,50,50,70)

Answer : C

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

A - $

B - //

C - /*.... */

D - #

Answer : D

python_questions_answers.htm
Advertisements