ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: C. False

float(2**53 + 1) rounds to 2**53 because doubles cannot store odd integers above 2**53. Python compares an int with a float exactly, so 2**53 + 1 and 2.0**53 differ.

More Python Programming questions

Exams that ask this topic