ProgrammingVery hardJEE Main · CAT placement

What is printed?

What is printed?
print(10**20 + 1 - 10**20, float(10**20 + 1) - float(10**20))
  1. A. 1 1.0
  2. B. 1 0.0
  3. C. 0 0.0
  4. D. 1 16384.0

Correct answer: B. 1 0.0

Python ints are exact, so the first difference is 1. 10**20 + 1 needs more than 53 bits, so float() rounds it back to 10**20, and the float difference is 0.0.

More Python Programming questions

Exams that ask this topic