Python math.pow()メソッド
例
9の値を3の累乗で求めます。
# Import math Library
import math
#Return the value of 9 raised
to the power of 3
print(math.pow(9, 3))
定義と使用法
このmath.pow()
メソッドは、xの値をyの累乗で返します。
xが負で、yが整数でない場合、ValueErrorを返します。
このメソッドは、両方の引数をfloatに変換します。
ヒント:math.pow(1.0,x)
またはを使用するmath.pow(x,0.0)
と、常に1.0が返されます。
構文
math.pow(x, y)
パラメータ値
Parameter | Description |
---|---|
x | Required. A number which represents the base |
y | Required. A number which represents the exponent |
技術的な詳細
戻り値: | xのfloat 値をyの累乗(x y)で表す値 |
---|