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 −

raining'. find('z') ?

A - Type error

B - ' '

C - -1

D - Not found

Answer : C

Explanation

If the string is not found by method find() , it returns the integer -1.

Q 2 - What is output for −

b = [11,13,15,17,19,21]

ptint(b[::2])

A - [19,21]

B - [11,15]

C - [11,15,19]

D - [13,17,21]

Answer : C

Explanation

b[::2] :- it iterates over the list with ‘2' increments

Q 3 - Which operator is right-associative

A - *

B - =

C - +

D - %

Answer : B

Explanation

‘=‘ operator is right associative as assignment operators are right associative.

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 - What command is used to insert 6 in a list ‘‘L'' at 3rd position ?

A - L.insert(2,6)

B - L.insert(3,6)

C - L.add(3,6)

D - L.append(2,6)

Answer : A

Explanation

listname.insert(x,y) method is used to insert a item at certain position in a list. x defines position at which the element will be added and y defines the element to be added in the list.

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.

Answer : D

Explanation

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 10 - Which is the special symbol used in python to add comments?

A - $

B - //

C - /*.... */

D - #

Answer : D

python_questions_answers.htm
Advertisements