121). What will be the output of the following Python code?
l=list('HELLO')
'first={0[0]}, third={0[2]}'.format(l)

[A]‘first=H, third=L’
[B]‘first=0, third=2’
[C]Error
[D]‘first=0, third=L’

Show Answer

122). What will be the output of the following Python code?
l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)

[A]Error
[B]“a=’H’, b=’O’, c=(E, L)”
[C]“a=H, b=O, c=[‘E’, ‘L’]”
[D]Junk value

Show Answer

123). The formatting method {1:<10} represents the ___________ positional argument, _________ justified in a 10 character wide field.
l=list('HELLO')
p=l[0], l[-1], l[1:3]
'a={0}, b={1}, c={2}'.format(*p)

[A]first, right
[B]second, left
[C]first, left
[D]second, right

Show Answer

124). What will be the output of the following Python code?
hex(255), int('FF', 16), 0xFF

[A][0xFF, 255, 16, 255]
[B](‘0xff’, 155, 16, 255)
[C]Error
[D](‘0xff’, 255, 255)

Show Answer

125). The output of the two codes shown below is the same.
bin((2**16)-1)
'{}'.format(bin((2**16)-1))

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

Show Answer

126). What will be the output of the following Python code?
'{a}{b}{a}'.format(a='hello', b='world')

[A]‘hello world’
[B]‘hello’ ‘world’ ‘hello’
[C]‘helloworldhello’
[D]‘hello’ ‘hello’ ‘world’

Show Answer

127). What will be the output of the following Python code?
 D=dict(p='san', q='jay')
'{p}{q}'.format(**D)

[A]Error
[B]sanjay
[C]san jay
[D]{‘san’, ‘jay’}

Show Answer

128). What will be the output of the following Python code?
'The {} side {1} {2}'.format('bright', 'of', 'life')

[A]Error
[B]‘The bright side of life’
[C]‘The {bright} side {of} {life}’
[D]No output

Show Answer

129). What will be the output of the following Python code?
'{0:f}, {1:2f}, {2:05.2f}'.format(1.23456, 1.23456, 1.23456)

[A]Error
[B]‘1.234560, 1.22345, 1.23’
[C]No output
[D]‘1.234560, 1.234560, 01.23’

Show Answer

130). What will be the output of the following Python code?
'%.2f%s' % (1.2345, 99)

[A]‘1.2345’, ‘99’
[B]‘1.2399’
[C]‘1.234599’
[D]1.23, 99

Show Answer

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

Show Answer

132). What will be the output of the following two codes?
i. '{0}'.format(4.56)
ii. '{0}'.format([4.56,])

[A] ‘4.56’, ‘4.56,’
[B]‘4.56’, ‘[4.56]’
[C]4.56, [4.56,]
[D]4.56, [4.56,]

Show Answer