Python Online Quiz


Advertisements

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 −

' ' in 'python' ?

A - 'python'

B - False

C - Name error

D - True

Answer : D

Explanation

To strings connected by ‘in’ operator gives true and false.

Q 2 - What is the output of following code −

[ (a,b) for a in range(3) for b in range(a) ]

A - [ (1,0),(2,1),(3,2)]

B - [ (0,0),(1,1),(2,2)]

C - [(1,0),(2,1),(2,1)]

D - [ (1,0),(2,0),(2,1)]

Answer : D

Explanation

This is nested for loop. The output of first for loop will be the value for the next loop.

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

def func(n):
   if(n==1):
      return 1;
   else:
      return(n+func(n-1))
print(func(4))

A - 12

B - 10

C - 9

D - 11

Answer : B

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.

Q 7 - Suppose you are given a set(s1={1,2,3}) then what is the output for the code −

2 * s1?

A - (1,1,2,2,3,3)

B - [1,1,2,2,3,3]

C - Illegal

D - (1,2,3,1,2,3)

Answer : C

Explanation

* cannot be operated on the sets.

Answer : C

Explanation

Frame() method is used to make a frame in python.

Q 9 - Which way among them is used to create an event loop ?

A - Window.eventloop()

B - Window.mainloop()

C - Window.loop()

D - Eventloop.window()

Answer : B

Q 10 - Best part is you can display images in various options in Python. Select the option where you can display an image −

A - Only A label

B - Only A button and A label

C - Only A checkbox

D - A label, a check box , a button and a radio button.

Answer : D

python_questions_answers.htm
Advertisements