280). What will be the output of the following Python code?
print("Hello {name1} and {name2}".format(name1='foo', name2='bin'))

[A]Hello foo and bin
[B]Hello {name1} and {name2}
[C]Error
[D]Hello and

Show Answer

281). What will be the output of the following Python code?
print("Hello {0!r} and {0!s}".format('foo', 'bin'))

[A]Hello foo and foo
[B]Hello ‘foo’ and foo
[C]Hello foo and ‘bin’
[D]Error

Show Answer

282). What will be the output of the following Python code?
print("Hello {0} and {1}".format(('foo', 'bin')))

[A]Hello foo and bin
[B]Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
[C]Error
[D]None of the mentioned

Show Answer

283). What will be the output of the following Python code?
print("Hello {0[0]} and {0[1]}".format(('foo', 'bin')))

[A]Hello foo and bin
[B]Hello (‘foo’, ‘bin’) and (‘foo’, ‘bin’)
[C]Error
[D]None of the mentioned

Show Answer

284). What will be the output of the following Python code snippet?
print('The sum of {0} and {1} is {2}'.format(2, 10, 12))

[A]The sum of 2 and 10 is 12
[B]Error
[C]The sum of 0 and 1 is 2
[D]None of the mentioned

Show Answer

285). What will be the output of the following Python code snippet?
print('The sum of {0:b} and {1:x} is {2:o}'.format(2, 10, 12))

[A]The sum of 2 and 10 is 12
[B]The sum of 10 and a is 14
[C]The sum of 10 and a is c
[D]Error

Show Answer

286). What will be the output of the following Python code snippet?
print('{:,}'.format(1112223334))

[A]1,112,223,334
[B]111,222,333,4
[C]1112223334
[D]Error

Show Answer