Python math.sqrt()メソッド
例
異なる数の平方根を見つけます。
# Import math Library
import math
# Return the square root of
different numbers
print (math.sqrt(9))
print (math.sqrt(25))
print
(math.sqrt(16))
定義と使用法
このmath.sqrt()
メソッドは、数値の平方根を返します。
注:数値は0以上である必要があります。
構文
math.sqrt(x)
パラメータ値
Parameter | Description |
---|---|
x | Required. A number to find the square root of. If the number is less than 0, it returns a ValueError. If the value is not a number, it returns a TypeError |
技術的な詳細
戻り値: | float 数値の平方根を表す値 |
---|---|
Pythonバージョン: | 1.4 |