Python Programming (2180711) MCQs

MCQs of Introduction to Python

Showing 151 to 160 out of 170 Questions
151.
What will be the output of the following Python code? d = {0, 1, 2} for x in d: print(x)
(a) 0 1 2
(b) {0, 1, 2} {0, 1, 2} {0, 1, 2}
(c) error
(d) none of the mentioned
Answer:

Option (a)

152.
What will be the output of the following Python code? d = {0, 1, 2} for x in d: print(d.add(x))
(a) 0 1 2
(b) 0 1 2 0 1 2 0 1 2 …
(c) None None None
(d) None of the mentioned
Answer:

Option (c)

153.
What will be the output of the following Python code? for i in range(0): print(i)
(a) 0
(b) no output
(c) error
(d) none of the mentioned
Answer:

Option (b)

154.
What will be the output of the following Python code? for i in range(2.0): print(i)
(a) 0.0 1.0
(b) 0 1
(c) error
(d) none of the mentioned
Answer:

Option (c)

155.
What will be the output of the following Python code? for i in range(int(2.0)): print(i)
(a) 0.0 1.0
(b) 0 1
(c) error
(d) none of the mentioned
Answer:

Option (b)

156.
What will be the output of the following Python code? for i in range(float('inf')): print (i)
(a) 0.0 0.1 0.2 0.3 …
(b) 0 1 2 3 …
(c) 0.0 1.0 2.0 3.0 …
(d) none of the mentioned
Answer:

Option (d)

157.
What will be the output of the following Python code snippet? for i in [1, 2, 3, 4][::-1]: print (i)
(a) 1 2 3 4
(b) 4 3 2 1
(c) error
(d) none of the mentioned
Answer:

Option (b)

158.
What will be the output of the following Python code snippet? for i in ''.join(reversed(list('abcd'))): print (i)
(a) a b c d
(b) d c b a
(c) error
(d) none of the mentioned
Answer:

Option (b)

159.
What will be the output of the following Python code snippet? for i in 'abcd'[::-1]: print (i)
(a) a b c d
(b) d c b a
(c) error
(d) none of the mentioned
Answer:

Option (b)

160.
What will be the output of the following Python code snippet? for i in '': print (i)
(a) None
(b) (nothing is printed)
(c) error
(d) none of the mentioned
Answer:

Option (b)

Showing 151 to 160 out of 170 Questions