ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

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

Correct answer: A. 10000000000000001 True

1e16 converts to the exact int 10**16, and adding 1 gives 10000000000000001. 2**60 + 1 needs more than 53 bits, so converting it to float rounds to 2**60 and the comparison is True.

More Python Programming questions

Exams that ask this topic