ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(format(1234.5678, '.2f'), format(1234.5678, '.2e'), format(0.000012345, '.3g'), format(12345.6789, ',.1f'))
  1. A. 1234.57 1.23e+03 0.0000123 12,345.7
  2. B. 1234.57 1.2e+03 1.23e-05 12,345.7
  3. C. 1234.57 1.23e+03 1.23e-05 12,345.7
  4. D. 1234.56 1.23e+03 1.23e-05 12,345.7

Correct answer: C. 1234.57 1.23e+03 1.23e-05 12,345.7

The g format switches to exponent form for values below 1e-4, so 0.000012345 shows as 1.23e-05. The comma flag adds thousands separators after the rounding.

More Python Programming questions

Exams that ask this topic