Python Math pow() Method
The Python Math pow() method returns the value of xy (the yth power of x).
Python Math pow() Syntax
Here is the syntax of the pow() method of the math module:
import math
math.pow( x, y )
The built-in pow() method:
pow(x, y[, z])
function is to calculate the yth power of x. If z is in existence, the result is then modulo the result, which is equivalent to pow(x,y) %z
Note: pow() is called directly via the built-in method, which takes the argument as an integer, while the math module converts the argument to float.
Python Math pow() Parameters
- x – Numeric expression.
- y – Numeric expression.
- z – Numeric expression.
Python Math pow() Return Value
Returns the value of xy (yth power of x).
Python Math pow() Example
The following shows an example of using the pow() method.
#!/usr/bin/python3
import math
print ("math.pow(100, 2) : ", math.pow(100, 2))
# Use the built-in to see the difference in output results
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))
Output: