ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(int(1e23), int(1e20))
  1. A. 100000000000000000000000 100000000000000000001
  2. B. 99999999999999991611392 100000000000000000000
  3. C. 100000000000000000000000 100000000000000000000
  4. D. 99999999999999999999999 100000000000000000000

Correct answer: B. 99999999999999991611392 100000000000000000000

1e23 cannot be stored exactly as a double, and the nearest double is 99999999999999991611392. 1e20 is exactly representable, so int(1e20) keeps all its digits.

More Python Programming questions

Exams that ask this topic