ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print('%05.1f|%x|%o|%e' % (3.14159, 255, 8, 12345.678))
  1. A. 003.1|ff|10|12345.678000
  2. B. 003.1|ff|10|1.234568e+04
  3. C. 3.1|FF|10|1.234568e+04
  4. 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

Exams that ask this topic