Python math.pow() Method
Example
Find the value of 9 raised to the power of 3:
# Import math Library
import math
#Return the value of 9 raised
to the power of 3
print(math.pow(9, 3))
Try it Yourself »
Definition and Usage
The math.pow()
method returns the value of x raised to power y.
If x is negative and y is not an integer, it returns a ValueError.
This method converts both arguments into a float.
Tip: If we use math.pow(1.0,x)
or math.pow(x,0.0)
, it will always returns 1.0.
Syntax
math.pow(x, y)
Parameter Values
Parameter | Description |
---|---|
x | Required. A number which represents the base |
y | Required. A number which represents the exponent |
Technical Details
Return Value: | A float value, representing the value of x to the power of y (xy) |
---|
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.