ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
x = 10**20 + 1
y = float(x)
print(int(y) == x, int(y) - x, y == 10**20, float(x) == y)
  1. A. True -1 True True
  2. B. False 2 True True
  3. C. False -1 False True
  4. D. False -1 True True

Correct answer: D. False -1 True True

Converting to float rounds 10**20 + 1 back to 10**20, so int(y) differs from x by -1. The round trip is lossy, but both float conversions produce the same double.

More Python Programming questions

Exams that ask this topic