What is math.pow() in Python?
The pow() function calculates the value of the power of another
Figure 1 shows the mathematical representation of the pow() function.
The
mathmodule is required for this function.
Syntax
pow(baseNumber, exponent)
Parameters
The pow() function requires two parameters:
- A base number.
- An exponent number.
Return value
pow() returns the value of the base number raised to the exponent number.
Example
import math#positive: baseNumber positive: exponentprint "The value of pow(2,3) : ", math.pow(2,3)#positive: baseNumber negative: exponentprint "The value of pow(0.25,-2) : ", math.pow(0.25,-2)#negative: baseNumber positive: exponentprint "The value of pow(-10,2) : ", math.pow(-10,2)#negative: baseNumber negative: exponentprint "The value of pow(-0.5,-1) : ", math.pow(-0.5,-1)