ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(1e-7 == 0.0000001, 1e-7, 0.0000001, 1.0e5 == 100000.0, 123e-2)
  1. A. True 1e-07 1e-07 True 1.23
  2. B. True 0.0000001 0.0000001 True 1.23
  3. C. False 1e-07 1e-07 True 1.23
  4. D. True 1e-07 1e-07 True 0.0123

Correct answer: A. True 1e-07 1e-07 True 1.23

Floats below 1e-4 print in scientific notation, and the exponent has at least two digits, so 1e-07. The two literals name the same double, so they compare equal.

More Python Programming questions

Exams that ask this topic