Python中指数运算有两种实现方式:
1.针对指数为 
即开根号:Python中sqrt()
函数返回x
的平方根(x > 0
)。
语法:
- import math
- math.sqrt(x)
2.针对其他次方
利用pow(a, b)
函数。需要开a
的r
次方则pow(a, r)
。
例如:
pow(a, 1.0/2),等价于a开2次根号
pow(a, 2),等于a的2次方
即开根号:Python中sqrt()
函数返回x
的平方根(x > 0
)。
语法:
- import math
- math.sqrt(x)
利用pow(a, b)
函数。需要开a
的r
次方则pow(a, r)
。
例如:
pow(a, 1.0/2),等价于a开2次根号
pow(a, 2),等于a的2次方