ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print('{:e}'.format(1234.5), '{:.3g}'.format(1234567), '{:g}'.format(0.0001), '{:g}'.format(0.00001))
  1. A. 1.2345e+03 1.23e+06 0.0001 1e-05
  2. B. 1.234500e+03 1.23e+6 0.0001 1e-5
  3. C. 1.234500e+03 1.23e+06 0.0001 1e-05
  4. D. 1.234500e+03 1.23e+06 0.0001 0.00001

Correct answer: C. 1.234500e+03 1.23e+06 0.0001 1e-05

The e format uses six decimals by default. .3g keeps three significant digits and switches to exponent form for large values, while g uses exponent form for values below 1e-4.

More Python Programming questions

Exams that ask this topic