ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
import math
print(math.isclose(0.1 + 0.2, 0.3), math.isclose(1e-12, 0), math.isclose(1e-12, 0, abs_tol=1e-9))
  1. A. True False True
  2. B. False False True
  3. C. True True True
  4. D. True False False

Correct answer: A. True False True

isclose uses relative tolerance by default, so a tiny value can never be close to 0 without an absolute tolerance. Passing abs_tol=1e-9 makes it True.

More Python Programming questions

Exams that ask this topic