Contents
Python math.isqrt()
math.isqrt(x) function returns the integer square root of non-negative integer x.
The return value of isqrt(x) is equivalent to the floor of sqrt(x).
Syntax
The syntax to call isqrt() function is
math.isqrt(x)
where
Parameter | Required | Description |
---|---|---|
x | Yes | A non-negative integer. |
Examples
Integer Square root of 11.
Python Program
import math
x = 11
result = math.isqrt(x)
print('isqrt(x) :', result)
Run Output
isqrt(x) : 3
Since isqrt() accepts only integer value, if float value is passed as argument to it, the function raises TypeError.
Python Program
import math
x = 11.5
result = math.isqrt(x)
print('isqrt(x) :', result)
Run Output
TypeError: 'float' object cannot be interpreted as an integer
Summary
In this Python Examples tutorial, we learned the syntax of, and examples for math.isqrt() function.