ProgrammingVery hardTCS NQT · Accenture

What is printed?

What is printed?
print(round(1.0000000000000002, 15) == 1, 1.0000000000000002 == 1, 1.0000000000000002 - 1 == 2.220446049250313e-16)
  1. A. False True False
  2. B. True True True
  3. C. True False False
  4. D. True False True

Correct answer: D. True False True

Rounding to 15 places removes the tiny excess, so the first check is True. The literal is one ulp above 1, so it is not equal to 1, and its excess is exactly 2**-52.

More Python Programming questions

Exams that ask this topic