Python cmath.sqrt()メソッド
例
複素数の平方根を求めます。
#Import cmath Library
import cmath
#Return the square root of a
complex number
print (cmath.sqrt(2 + 3j))
print (cmath.sqrt(15))
定義と使用法
このcmath.sqrt()
メソッドは、複素数の平方根を返します。
注:数値は0以上である必要があります。
構文
cmath.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 |
技術的な詳細
戻り値: | complex 複素数の平方根を表す値 |
---|---|
Pythonバージョン: | 1.5 |