ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
from math import isqrt
print(isqrt(10**30), isqrt(99), isqrt(10**30 - 1))
  1. A. 1000000000000000 10 999999999999999
  2. B. 1000000000000000 9 1000000000000000
  3. C. 999999999999999 9 999999999999999
  4. D. 1000000000000000 9 999999999999999

Correct answer: D. 1000000000000000 9 999999999999999

isqrt returns the floor of the exact square root. The square root of 10**30 is 10**15 exactly, while 10**30 - 1 falls just below it, and isqrt(99) is 9.

More Python Programming questions

Exams that ask this topic