Python Programming (2180711) MCQs

MCQs of Introduction to Python

Showing 111 to 120 out of 170 Questions
111.
What will be the output of the following Python code? '%s' %((1.23,),)
(a) ‘(1.23,)’
(b) 1.23,
(c) (,1.23)
(d) ‘1.23’
Answer:

Option (a)

112.
What will be the output of the following two codes? '{0}'.format(4.56) '{0}'.format([4.56,])
(a) ‘4.56’, ‘4.56,’
(b) ‘4.56’, ‘[4.56]’
(c) 4.56, [4.56,]
Answer:

Option (b)

113.
What will be the output of the following Python code? 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:

Option (a)

114.
What will be the output of the following Python code? x = ['ab', 'cd'] for i in x: x.append(i.upper()) print(x)
(a) [‘AB’, ‘CD’]
(b) [‘ab’, ‘cd’, ‘AB’, ‘CD’]
(c) [‘ab’, ‘cd’]
(d) none of the mentioned
Answer:

Option (d)

115.
What will be the output of the following Python code? i = 1 while True: if i%3 == 0: break print(i)   i + = 1
(a) 1 2
(b) 1 2 3
(c) error
(d) none of the mentioned
Answer:

Option (c)

116.
What will be the output of the following Python code? i = 1 while True: if i%0O7 == 0: break print(i) i += 1
(a) 1 2 3 4 5 6
(b) 1 2 3 4 5 6 7
(c) error
(d) none of the mentioned
Answer:

Option (a)

117.
What will be the output of the following Python code? i = 5 while True: if i%0O11 == 0: break print(i) i += 1
(a) 5 6 7 8 9 10
(b) 5 6 7 8
(c) 5 6
(d) error
Answer:

Option (b)

118.
What will be the output of the following Python code? i = 5 while True: if i%0O9 == 0: break print(i) i += 1
(a) 5 6 7 8
(b) 5 6 7 8 9
(c) 5 6 7 8 9 10 11 12 13 14 15 ….
(d) error
Answer:

Option (d)

119.
What will be the output of the following Python code? i = 1 while True: if i%2 == 0: break print(i) i += 2
(a) 1
(b) 1 2
(c) 1 2 3 4 5 6 …
(d) 1 3 5 7 9 11 …
Answer:

Option (d)

120.
What will be the output of the following Python code? i = 2 while True: if i%3 == 0: break print(i) i += 2
(a) 2 4 6 8 10 …
(b) 2 4
(c) 2 3
(d) error
Answer:

Option (b)

Showing 111 to 120 out of 170 Questions