Latest web development tutorials

python3 SQRT()関数

python3デジタル python3デジタル


説明

SQRT()メソッドは、数値xの平方根を返します。


文法

以下は、構文のsqrt()メソッドです。

import math

math.sqrt( x )

注:SQRT()は直接アクセスできません、あなたは数学のモジュールをインポートする必要があり、静的オブジェクトを介してメソッドを呼び出します。


パラメータ

  • X - 数値式。

戻り値

数xの平方根を返します。

以下は、SQRT()メソッドの使用例を示します。

#!/usr/bin/python3
import math   # 导入 math 模块

print ("math.sqrt(100) : ", math.sqrt(100))
print ("math.sqrt(7) : ", math.sqrt(7))
print ("math.sqrt(math.pi) : ", math.sqrt(math.pi))

上の例の出力を実行した後です。

math.sqrt(100) :  10.0
math.sqrt(7) :  2.6457513110645907
math.sqrt(math.pi) :  1.7724538509055159

python3デジタル python3デジタル