python math.pow()方法,求幂次方
math.pow()方法
python标准库math模块的pow()方法,可以参数指定的x的y次方的值。
math.pow()语法
math.pow(x, y)
python源码对math.pow()方法的介绍:
Return x**y (x to the power of y).
参数
参数 | 描述 |
---|---|
x | 必须参数,real number,如int或float等类型 |
y | 必须参数,real number,如int或float等类型 |
返回值
python浮点数float类型值。
math.pow()方法实例代码
>>> import math
>>> math.pow(2,5)
32.0
>>> math.pow()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: pow expected 2 arguments, got 0