ProgrammingVery hardProduct-company MCQ pattern

What is printed on the first line?

What is printed on the first line?
print(2**63 * 2**-63 == 1.0, 2**64 + 1.0 - 2**64, (2**64 + 1) - 2**64)
print(float(2**64 + 1) - float(2**64))
  1. A. True 2.0 1
  2. B. False 0.0 1
  3. C. True 0.0 2
  4. D. True 0.0 1

Correct answer: D. True 0.0 1

2**64 + 1.0 loses the +1 because the float cannot hold it, but the all-int expression keeps it exactly. Converting both operands to floats first gives 0.0 as well.

More Python Programming questions

Exams that ask this topic