ProgrammingModerateTCS NQT · Infosys
What relative and absolute tolerances does math.isclose use by default?
- A. rel_tol 0.0 and abs_tol 1e-09
- B. rel_tol 1e-06 and abs_tol 1e-12
- C. rel_tol 1e-09 and abs_tol 0.0
- 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
- Which key sorts records by score descending and then by name ascending, using one stable sort?
- What is the largest float that is less than 1.0 in Python, as printed by repr?
- What is printed? python print(3 // 2 2 + 3 % 2, -3 // 2 2 + -3 % 2)
- What is printed? python print('%s and %r' % ('a', 'a'))
- What is printed? python print('-'.join(map(str, range(3, 0, -1))))
- What is printed? python print('abc'[-1:-4:-1], 'abc'[5:], 'abc'[-10:2])