ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(1e22, 1e21, 1e16, 1e15, 1e-5, 0.0001)
  1. A. 1e+22 1e+21 1e+16 1e+15 1e-05 0.0001
  2. B. 1e22 1e21 1e16 1000000000000000.0 1e-5 0.0001
  3. C. 1e+22 1e+21 1e+16 1000000000000000.0 1e-05 0.0001
  4. D. 1e+22 1e+21 10000000000000000.0 1000000000000000.0 1e-05 0.0001

Correct answer: C. 1e+22 1e+21 1e+16 1000000000000000.0 1e-05 0.0001

repr() uses scientific notation when the exponent is below -4 or at least 16. So 1e15 prints in full with a trailing .0, while 1e16 switches to 1e+16 and 1e-5 prints as 1e-05.

More Python Programming questions

Exams that ask this topic