ProgrammingHardJEE Advanced · CAT placement

What is printed?

What is printed?
import math
print(math.fsum([0.1] * 10) == 1.0, sum([0.1] * 10) == 1.0, math.isqrt(10 ** 30 - 1))
  1. A. False True 999999999999999
  2. B. True True 999999999999999
  3. C. True False 1000000000000000
  4. D. True True 1000000000000000

Correct answer: B. True True 999999999999999

fsum and the compensated sum() of Python 3.12 and later both round the exact total of ten copies of 0.1 to 1.0. isqrt gives the floor of the square root, and sqrt(10**30 - 1) is just under 10**15.

More Python Programming questions

Exams that ask this topic