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 the output for −

'Tutorials Point' [100:200]?

A - Index error.

B - ' '

C - 'Tutorials Point'

D - Syntax error

Answer : B

Explanation

Slicing will never give us an error even if we give it too large of an index for the string. It will just return the widest matching slice it can.

Q 2 - Which of the following is false statement in python

A - int(144)==144

B - int('144')==144

C - int(144.0)==144

D - None of the above

Answer : D

Explanation

The built-in int() type constructor converts string and floating value to integer.

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.

Answer : B

Explanation

If A is proper subset of B then hen all elements of A are in B but B contains at least one element that is not in B.

Q 5 - What will be the output of the following code?

def total(initial = 5, *num, **key):
   count = initial
   for n in num:
      count+=n
   for k in key:
      count+=key[k]
   return count
print(total(100,2,3, clouds=50, stars=100))

A - 260

B - 160

C - 155

D - 255

Answer : D

Explanation

It takes initial value as 100 now. And adds 2, 3, 50 and 100 to it as according to code.

Answer : B

Explanation

x is the object created by the constructor of the class Circle().

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

For the type of message user want to display on the window of python there is a type of code according to it. Example for warning message user choose showwarning method.

Q 9 - Suppose you are using a grid manager then which option is best suitable to place a component in multiple rows and columns?

A - Columnspan and rowspan

B - Only row

C - Only column

D - Only rowspan

Answer : A

Q 10 - What will be the output of the following code?

print(type(1/2))

A - <class 'float'>

B - <class 'int'>

C - NameError: ‘½' is not defined.

D - 0.5

Answer : A

Explanation

Output of ½ is 0.5.

python_questions_answers.htm
Advertisements