ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(str(1e-5), 0.0001, 0.00001, 1e-4 == 0.0001, 10 ** -4)
  1. A. 0.00001 0.0001 0.00001 True 0.0001
  2. B. 1e-05 0.0001 1e-05 False 0.0001
  3. C. 1e-05 0.001 1e-05 True 0.0001
  4. D. 1e-05 0.0001 1e-05 True 0.0001

Correct answer: D. 1e-05 0.0001 1e-05 True 0.0001

Floats smaller than 1e-4 print in exponent form with at least two exponent digits, so 0.00001 shows as 1e-05. 0.0001 is printed in full, and 10 ** -4 is the same float as the literal.

More Python Programming questions

Exams that ask this topic