ProgrammingVery hardProduct-company MCQ pattern

What is printed?

What is printed?
print(0.1 * 3 != 0.3, abs(0.1 * 3 - 0.3) < 2**-52, abs(0.1 * 3 - 0.3) < 2**-54)
  1. A. True False False
  2. B. False True True
  3. C. True True False
  4. D. True True True

Correct answer: C. True True False

0.1 * 3 is one unit above 0.3, which is about 5.55e-17. That is smaller than 2**-52 but not smaller than 2**-54, so a tolerance this tight fails.

More Python Programming questions

Exams that ask this topic