Python Section 4 - MCQ
1 .
What is the value of colors[2]?
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']​

Correct Answer : Option (B)

yellow
2 .
What is the output of the following code?
print(3 >= 3)​

Correct Answer : Option (A)

True
3 .
what is the output of the following code?
print(type([1,2]))​

Correct Answer : Option (C)

<class 'list'>
4 .
What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]​

Correct Answer : Option (D)

o
5 .
What is the output when following code is executed ?
>>>str1="helloworld"
>>>str1[::-1]

Correct Answer : Option (A)

dlrowolleh
6 .
What will be printed:
def f(a, b):
 print(a, b)
f(b=1, *(2,))​

Correct Answer : Option (B)

2 1
7 .
What is inheritance used for?

Correct Answer : Option (A)

To give a class the methods and variables of an interface
8 .
What will be placed in a?
a = [1,2,3]
a[-3:-1] = 10,20,30,40

Correct Answer : Option (B)

[10, 20, 30, 40, 3]
9 .
What does this function return?
def f(a,b):
 return a,b
f(**{'b':2,'a':1})​

Correct Answer : Option (A)

(1, 2)
10 .
Which of these is not a Python datatype?

Correct Answer : Option (C)

decimal