ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print(int(1e22) == 10**22, int(1e23) == 10**23, 1e23 == 10**23, float(10**23) == 1e23)
  1. A. True False False True
  2. B. True True True True
  3. C. True False True True
  4. D. False False False True

Correct answer: A. True False False True

1e22 is exactly representable, but 1e23 is not, so int(1e23) is 99999999999999991611392 rather than 10**23. Comparing a float with an int is exact, so 1e23 == 10**23 is False, while float(10**23) rounds to the same double as 1e23.

More Python Programming questions

Exams that ask this topic