ProgrammingModerateTCS NQT · Infosys
What is printed?
What is printed?
print('%05.1f|%x|%o|%e' % (3.14159, 255, 8, 12345.678))- A. 003.1|ff|10|12345.678000
- B. 003.1|ff|10|1.234568e+04
- C. 3.1|FF|10|1.234568e+04
- D. 003.1|ff|10|1.2346e+04
Correct answer: B. 003.1|ff|10|1.234568e+04
%05.1f pads to width 5 with zeros, %x is lowercase hex, %o is octal, and %e uses six decimal places in scientific notation with a two-digit exponent. Upper-case FF would need %X.
More Python Programming questions
- What is printed? python print(f'{-5:+}', f'{5:+}', f'{3.0:g}', f'{1e6:g}', f'{1e-5:g}', f'{123456789.0:g}')
- What is printed? python print(f'{12345678:,}', f'{0.5:.0%}', f'{2.5:.0f}', f'{3.5:.0f}', f'{-0.4:.0f}')
- What is printed? python print(repr(1e16), repr(1e15 + 0.3), 1e16 == 1016, 1e16 + 1 == 1e16)
- What is printed? python print(10 -2, 10.0 -2, 1000 10, 2 -1 4)
- What is printed? python print(bool(0.0), bool(-0.0), bool(float('nan')), bool(' '), bool('0'), bool(0j))
- What is printed? python s1 = 'u00e9' s2 = 'eu0301' print(s1 == s2, len(s1), len(s2), len(s2.encode()), s2 == 'eu0301')