Python pow() Function
Python pow() Function
The pow() function in Python return the parameter ‘x’ to the power ‘y’ and if the parameter ‘z’ is present, it returns x to the power y, modulo z (computed more efficiently than pow(x, y) % z).
Syntax
pow(x, y[, z])
Parameter
x: This parameter represents the base number.
y: This parameter represents the exponent number
z: It is an optional parameter that represents the modulus.
Return
This function returns x to the power y; if z is present, return x to the power y, modulo z.
Example 1
# Python program explaining
# the pow() function
num = 1
for i in range(1,5):
num=3*num
print ("The value of 3**4 is: ",end="")
print (num)
# representing the above with pow() class method
print("After calling the pow() method")
print ("The pow value of 3**4 is:",pow(3,4))
Output
The value of 3**4 is: 81 After calling the pow() method The pow value of 3**4 is: 81
