Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.isqrt() Method

Python math.isqrt() Method

Python math Module Python math Module

Python math.isqrt(x) The method returns the square root of x, rounded down to the nearest integer.

The number must be greater than or equal to 0.

Python version: 3.8

Syntax

The syntax of the math.isqrt() method is as follows:

math.isqrt(x)

Parameter Description:

Return Value

Returns an integer int representing the square root of a number, rounded down to the nearest integer.

Example

The following example returns the square root of numbers, rounded down to the nearest integer:

Example

Import the math package

import

math

Output the square root

Print the square root of different numbers

print

(

math

.

sqrt

(

10

)

)

print

(

math

.

sqrt

(

12

)

)

print

(

math

.

sqrt

(

68

)

)

print

(

math

.

sqrt

(

100

)

)

Output the square root, rounded down to the nearest integer

print

(

math

.

isqrt

(

10

)

)

print

(

math

.

isqrt

(

12

)

)

print

(

math

.

isqrt

(

68

)

)

print

(

math

.

isqrt

(

100

)

)

Output result:


3.1622776601683795
3.4641016151377544
8.246211251235321
10.0
3
3
8
10

Python math Module Python math Module