Python/ref math isqrt
来自菜鸟教程
<languages />
Python math.isqrt()方法
例
将平方根向下取整至最接近的整数:
# Import math Library
import math
# Print the square
root of different numbers
print (math.sqrt(10))
print (math.sqrt (12))
print (math.sqrt (68))
print (math.sqrt (100))
# Round square root
downward to the nearest integer
print (math.isqrt(10))
print
(math.isqrt (12))
print (math.isqrt (68))
print (math.isqrt (100))
定义和用法
The
math.isqrt()
方法将平方根向下取整至最接近的整数。
注意: 该数字必须大于或等于0。
句法
math.isqrt(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 需要。要舍入的平方根的数字。If
x 如果为负,则返回ValueError。If x 不是数字,则返回TypeError |
技术细节
| 返回值: | An
|
| Python版本: | 3.8 |