106). What will be the output of the following Python code snippet?
'%d %s %g you' %(1, 'hello', 4.0)

[A]Error
[B]1 hello you 4.0
[C]1 hello 4 you
[D]1 4 hello you

Show Answer

107). The output of which of the codes shown below will be: “There are 4 blue birds.”?
'%d %s %g you' %(1, 'hello', 4.0)

[A]‘There are %g %d birds.’ %4 %blue
[B]‘There are %d %s birds.’ %(4, blue)
[C]‘There are %s %d birds.’ %[4, blue]
[D]‘There are %d %s birds.’ 4, blue

Show Answer

108). What will be the output of the python code shown below for various styles of format specifiers?
x=1234
res='integers:...%d...%-6d...%06d' %(x, x, x)
res

[A]‘integers:…1234…1234 …001234’
[B]‘integers…1234…1234…123400’
[C]‘integers:… 1234…1234…001234’
[D]‘integers:…1234…1234…001234’

Show Answer

109). What will be the output of the following Python code snippet?
x=3.3456789
'%f | %e | %g' %(x, x, x)

[A]Error
[B]‘3.3456789 | 3.3456789+00 | 3.345678’
[C]‘3.345678 | 3.345678e+0 | 3.345678’
[D]‘3.345679 | 3.345679e+00 | 3.34568’

Show Answer

110). 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+’

Show Answer

111). 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)

Show Answer

112). 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’

Show Answer

113). 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

Show Answer

114). 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

Show Answer

115). 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’

Show Answer

116). 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

Show Answer

117). 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]’

Show Answer

118). 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’

Show Answer

119). 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

Show Answer

120). The output of the two codes shown below is the same.
'{0:.2f}'.format(1/3.0)
'%.2f'%(1/3.0)

[A]True
[B]False
[C]1
[D]0

Show Answer