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))
定義と使用法
このmath.isqrt()
メソッドは、平方根数を最も近い整数に切り捨てます。
注:数値は0以上である必要があります。
構文
math.isqrt(x)
パラメータ値
Parameter | Description |
---|---|
x | Required. The number to round the square root of. If x is negative, it returns a ValueError. If x is not a number, it returns a TypeError |
技術的な詳細
戻り値: | 数値のint 平方根を表す値で、小数は含まれません |
---|---|
Pythonバージョン: | 3.8 |