Python Programming (2180711) MCQs

MCQs of Introduction to Python

Showing 91 to 100 out of 170 Questions
91.
What will be the output of the following Python code snippet? x=3.3456789 '%-6.2f | %05.2f | %+06.1f' %(x, x, x)
(a) ‘3.35 | 03.35 | +003.3’
(b) ‘3.3456789 | 03.3456789 | +03.3456789’
(c) Error
(d) ‘3.34 | 03.34 | 03.34+’
Answer:

Option (a)

92.
What will be the output of the following Python code snippet? x=3.3456789 '%s' %x, str(x)
(a) Error
(b) (‘3.3456789’, ‘3.3456789’)
(c) (3.3456789, 3.3456789)
(d) (‘3.3456789’, 3.3456789)
Answer:

Option (b)

93.
What will be the output of the following Python code snippet? '%(qty)d more %(food)s' %{'qty':1, 'food': 'spam'}
(a) Error
(b) No output
(c) ‘1 more foods’
(d) ‘1 more spam’
Answer:

Option (d)

94.
What will be the output of the following Python code snippet? a='hello' q=10 vars()
(a) {‘a’ : ‘hello’, ‘q’ : 10, ……..plus built-in names set by Python….}
(b) {……Built in names set by Python……}
(c) {‘a’ : ‘hello’, ‘q’ : 10}
(d) Error
Answer:

Option (a)

95.
What will be the output of the following Python code? s='{0}, {1}, and {2}' s.format('hello', 'good', 'morning')
(a) ‘hello good and morning’
(b) ‘hello, good, morning’
(c) ‘hello, good, and morning’
(d) Error
Answer:

Option (c)

96.
What will be the output of the following Python code? s='%s, %s & %s' s%('mumbai', 'kolkata', 'delhi')
(a) mumbai kolkata & delhi
(b) Error
(c) No output
(d) ‘mumbai, kolkata & delhi’
Answer:

Option (d)

97.
What will be the output of the following Python code? t = '%(a)s, %(b)s, %(c)s' t % dict(a='hello', b='world', c='universe')
(a) ‘hello, world, universe’
(b) ‘hellos, worlds, universes’
(c) Error
(d) hellos, world, universe
Answer:

Option (a)

98.
What will be the output of the following Python code? '{a}, {0}, {abc}'.format(10, a=2.5, abc=[1, 2])
(a) Error
(b) ‘2.5, 10, [1, 2]’
(c) 2.5, 10, 1, 2
(d) ’10, 2.5, [1, 2]’
Answer:

Option (b)

99.
What will be the output of the following Python code? '{0:.2f}'.format(1.234)
(a) ‘1’
(b) ‘1.234’
(c) ‘1.23’
(d) ‘1.2’
Answer:

Option (c)

100.
What will be the output of the following Python code? '%x %d' %(255, 255)
(a) ‘ff, 255’
(b) ‘255, 255’
(c) ‘15f, 15f’
(d) Error
Answer:

Option (a)

Showing 91 to 100 out of 170 Questions