ProgrammingVery hardProduct-company MCQ pattern

What is printed?

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

Correct answer: C. True False False

2**54 + 1 is not representable as a double, so the float rounds back to 2**54 and the first test is True. The int comparison is exact, so 2**54 + 1 is not equal to float(2**54).

More Python Programming questions

Exams that ask this topic