ProgrammingVery hardGATE CS · Product-company placement

What is printed?

What is printed?
print(2**53 + 1 == 2**53 + 1.0, 2**53 + 1 == 2**53, float(2**53 + 1) == 2**53)
  1. A. True False True
  2. B. False True True
  3. C. False False False
  4. D. False False True

Correct answer: D. False False True

The int 2**53 + 1 is exact, but 2**53 + 1.0 is a float that rounds to 2**53, and the int/float comparison is exact, so the first test is False. Converting the int to float first rounds down to 2**53, making the last test True.

More Python Programming questions

Exams that ask this topic