Python MCQ 2-1
Python MCQ 2-1
Python MCQ 2-1
Answer:
a) he
b) lo
c) olleh
d) hello
Answer:
Answer:
4. What error occurs when you execute the following Python code snippet?
apple = mango
a) SyntaxError
b) NameError
c) ValueError
d) TypeError
Answer:
L = [ 1, 23, ‘hello’,1]
a) list
b) dictionary
c) array
d) tuple
Answer:
6. In order to store values in terms of key and value we use what core data type.
a) list
b) tuple
c) class
d) dictionary
Answer:
Answer:
>>> grade1 = 80
>>>grade2 = 90
a) 85.0
b) 85.1
c) 95.0
d) 95.1
Answer:
hello-how-are-you
Answer:
Answer:
11. What will be the output of the following Python code snippet?
a) Error
b) 1 hello you 4.0
c) 1 hello 4 you
d) 1 4 hello you
Answer:
x = ['ab', 'cd']
for i in x:
i.upper()
print(x)
a) [‘ab’, ‘cd’]
b) [‘AB’, ‘CD’]
c) [None, None]
d) none of the mentioned
Answer:
x = "abcdef"
i = "a"
while i in x:
x = x[1:]
print(i, end = " ")
a) a a a a a a
b) a
c) no output
d) error
Answer:
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print("Here")
a) 0 1 2 3 4 Here
b) 0 1 2 3 4 5 Here
c) 0 1 2 3 4
d) 1 2 3 4 5
Answer:
15. What will be the output of the following Python code snippet?
a = [0, 1, 2, 3]
for a[-1] in a:
print(a[-1])
a) 0 1 2 3
b) 0 1 2 2
c) 3 3 3 3
d) error
Answer:
16. What will be the output of the following Python code snippet?
a) m, y, , n, a, m, e, , i, s, , x,
b) m, y, , n, a, m, e, , i, s, , x
c) my, name, is, x,
d) error
Answer:
>>>"a"+"bc"
a) a
b) bc
c) bca
d) abc
Answer:
18. What will be the output of the following Python code?
a) olleh
b) hello
c) h
d) o
Answer:
>>>print('new' 'line')
a) Error
b) Output equivalent to print ‘new\nline’
c) newline
d) new line
Answer: c
.
class tester:
def __init__(self, id):
self.id = str(id)
id="224"
>>>temp = tester(12)
>>>print(temp.id)
a) 224
b) Error
c) 12
d) None
Answer:
>>>chr(ord('A'))
a) A
b) B
c) a
d) Error
Answer:
Answer:
Answer:
Answer: