math.pow(x, y)
The math.pow function returns the result of raising x to y. Unlike the built-in function pow or the ** operator, math.pow always returns a real number, even if x and y are integers.
math.pow(1.0, x) and math.pow(x, 0.0) always return 1.0, regardless of the value of x. If x is a negative number and y is not an integer, math.pow(x, y) generates an error of type ValueError.
- x: Power base.
- y: Exponent of the power.
The math.pow function returns a real number.
We can obtain the result of raising the number 2.5 to 3.6 with the following code:
The result returned by the function is a real number even though the base and the exponent are integers: