Python3 pow () function
description
pow () method returns a value x y (x to the power of y) is.
grammar
The following is the syntax for math module pow () method:
import math math.pow( x, y )
Built-in pow () method
pow(x, y[, z])
Function computing power of x is y, if z is present, then the results are again modulo, the result is equivalent to the pow (x, y)% z
Note: pow () method called directly via the built-in, built-in method would parameter as an integer, and the math module parameters will be converted to float.
parameter
- x - numeric expression.
- y - numeric expression.
- z - a numeric expression.
return value
Return Value x y (x to the power of y) is.Examples
The following shows an example of using pow () method:
#!/usr/bin/python3 import math # 导入 math 模块 print ("math.pow(100, 2) : ", math.pow(100, 2)) # 使用内置,查看输出结果区别 print ("pow(100, 2) : ", pow(100, 2)) print ("math.pow(100, -2) : ", math.pow(100, -2)) print ("math.pow(2, 4) : ", math.pow(2, 4)) print ("math.pow(3, 0) : ", math.pow(3, 0))
After running the above example output is:
math.pow(100, 2) : 10000.0 pow(100, 2) : 10000 math.pow(100, -2) : 0.0001 math.pow(2, 4) : 16.0 math.pow(3, 0) : 1.0