ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
import math
print(math.isclose(0.1 + 0.2, 0.3), math.isclose(0.0, 1e-10), math.isclose(0.0, 1e-10, 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 with default settings is True for 0.1 + 0.2 and 0.3. A relative test cannot see that 0.0 is close to 1e-10, so the absolute tolerance is needed.

More Python Programming questions

Exams that ask this topic