ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(str(1e-4), str(1e-5), str(123456789.0), str(1234567890123456789.0))
  1. A. 0.0001 1e-05 123456789.0 1.2345678901234568e+18
  2. B. 0.0001 1e-5 123456789.0 1.2345678901234568e+18
  3. C. 0.0001 1e-05 123456789 1.2345678901234568e+18
  4. D. 0.0001 1e-05 123456789.0 1.2345678901234567e+18

Correct answer: A. 0.0001 1e-05 123456789.0 1.2345678901234568e+18

str() of a float uses scientific notation below 1e-4 with at least two exponent digits. A float with no fraction still shows .0, and a value of 1.2e18 uses the shortest round-trip digits.

More Python Programming questions

Exams that ask this topic