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

全栈后端 / Python库 :









Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.