ProgrammingHardGATE CS · Product-company placement

What is printed?

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

Correct answer: B. True False True True

isclose uses a relative tolerance by default, which can never succeed against 0, so an absolute tolerance is needed there. Comparing a float with a huge int is done exactly, and inf exceeds every int.

More Python Programming questions

Exams that ask this topic