ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

What is printed?
print(1e16 == 10**16, 1e16 + 1 == 10**16 + 1, 1e16 + 2 == 10**16 + 2, int(1e16) + 1)
  1. A. True True True 10000000000000001
  2. B. True False True 10000000000000001
  3. C. True False False 10000000000000000
  4. D. False False True 10000000000000001

Correct answer: B. True False True 10000000000000001

1e16 is exact, so the first check is True. 1e16 + 1 is not representable and rounds back, so the exact comparison with 10**16 + 1 fails. 1e16 + 2 is representable, and int(1e16) + 1 is exact.

More Python Programming questions

Exams that ask this topic