ProgrammingModerateTCS NQT · Infosys

What relative and absolute tolerances does math.isclose use by default?

  1. A. rel_tol 0.0 and abs_tol 1e-09
  2. B. rel_tol 1e-06 and abs_tol 1e-12
  3. C. rel_tol 1e-09 and abs_tol 0.0
  4. D. both are 0.0, so it means exact equality

Correct answer: C. rel_tol 1e-09 and abs_tol 0.0

math.isclose defaults to a relative tolerance of 1e-09 and no absolute tolerance, which is why comparing a value with 0 needs abs_tol passed explicitly.

More Python Programming questions

Exams that ask this topic