ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print('%.2e' % 0.000123456, '%G' % 1e-5, '%g' % 1e-5, '%.3g' % 1234.5)
  1. A. 1.23e-04 1E-05 1e-05 1.2e+03
  2. B. 1.23e-04 1E-05 1e-05 1234.5
  3. C. 1.23e-04 1E-05 1e-05 1.23e+03
  4. D. 1.2e-04 1E-05 1e-05 1.23e+03

Correct answer: C. 1.23e-04 1E-05 1e-05 1.23e+03

%g switches to exponent form when the exponent is below -4 or at least the precision, so 1234.5 with .3g becomes 1.23e+03. %G is the same as %g but uses an upper-case E.

More Python Programming questions

Exams that ask this topic