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

a = (1, 2)
a[0] +=1

A - (1,1,2)

B - 2

C - Type Error

D - Syntax Error

Answer : C

Explanation

TypeError − ‘tuple’ object does not support item assignment because a tuple is immutable.

Answer : B

Explanation

list are mutable whereas tuples are immutable i.e. in list changes can be made but in tuples it is not possible, they can only be operated its value cannot be changed.

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 is the output of the following code?

import math
 
   def main():
      math.cos(math.pi)
main()
   print(main())

A - -1

B - None

C - Error

D - Math.pi not defined

Answer : B

Explanation

None is printed because function does not return the value.

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.

Answer : C

Explanation

+ Operator cannot be operated on the sets.

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.

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 - 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

Useful Video Courses


Video

Python Online Training

Most Popular

187 Lectures 17.5 hours

Malhar Lathkar

Video

Python Essentials Online Training

55 Lectures 8 hours

Arnab Chakraborty

Video

Learn Python Programming in 100 Easy Steps

136 Lectures 11 hours

In28Minutes Official

Video

Python with Data Science

75 Lectures 13 hours

Eduonix Learning Solutions

Video

Python 3 from scratch to become a developer in demand

70 Lectures 8.5 hours

Lets Kode It

Video

Python Data Science basics with Numpy, Pandas and Matplotlib

63 Lectures 6 hours

Abhilash Nelson

Advertisements