ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(0.1 + 0.2 != 0.3, (0.1 + 0.2) - 0.3 < 1e-16, abs((0.1 + 0.2) - 0.3) <= 5e-17)
  1. A. True False False
  2. B. True True False
  3. C. False True False
  4. D. True True True

Correct answer: B. True True False

0.1 + 0.2 - 0.3 is about 5.55e-17, which is below 1e-16 but above 5e-17. Tolerance checks must pick a value that matches the error size.

More Python Programming questions

Exams that ask this topic