Python math.pow() Method
Python math.pow(x, y)The method returns x raised to the power of y.
If x is negative and y is not an integer, a ValueError is returned. The method converts both arguments to floating-point numbers. math.pow(1.0, x) or math.pow(x, 0.0) always returns 1.0.Syntax
The syntax of the math.pow() method is as follows:
math.pow(x, y)
Parameter description:
- x-- Required, a number representing the base.
- y-- Required, a number representing the exponent.
Return Value
Returns a floating-point number representing x raised to the power of y.
Example
The following example returns 9 to the 3rd power:
Example
# Import the math package
import math
# Output 9 to the 3rd power
print(math.pow(9, 3))
import math
# Output 9 to the 3rd power
print(math.pow(9, 3))
Output result:
729.0Other Extensions
Python math Module