python中如何求幂函数
python中如何求幂函数
python中可使用pow函数求幂,具体方法以下:
pow():pow()函数的作用是返回x的y次方的值。
pow()函数语法:
math.pow( x, y )
pow()函数使用方法:
import math #导入math模块
print "math.pow(100, 2) : ", math.pow(100, 2)
print "math.pow(100, ⑵) : ", math.pow(100, ⑵)
print "math.pow(2, 4) : ", math.pow(2, 4)
print "math.pow(3, 0) : ", math.pow(3, 0)
输出结果为:
math.pow(100, 2) : 10000.0
math.pow(100, ⑵) : 0.0001
math.pow(2, 4) : 16.0
math.pow(3, 0) : 1.0
文章来源:丸子建站
文章标题:python中如何求幂函数
https://www.wanzijz.com/view/4820.html