Introduction
The pow() function in Python returns the power of a number entered. It is built into Python and returns the result of the value of x to the power of y. If a 3rd parameter appears, the pow() will return x power of y, modulus z. This function converts its arguments to float first and then calculates the exponentiation.
Now we’re gonna guide you about using the pow() function in Python. Hope you understand.
Example
x = pow(2, 4) print(x)
Output:
16
Definition
The pow() function will print out the result of the value of x power of y.
If a 3rd parameter appears, the function will return x power of y, modulus z.
The syntax
pow(x, y, z)
Parameter Values:
x: radix (required)
y: exponent (required)
z: modulus (optional)
More examples
Example 1: Basic pow() function
x = pow(3, 3) print(x)
Output:
27
Example 2: pow() with three argument
x = pow(2, 4, 10) print(x)
Output:
6
Example 3: pow() combines input()
print("Enter the radix: ") x = int(input()) print("Enter the exponent: ") y = int(input()) power = pow(x,y) print("Result:",power)
Output:
Enter the radix: 2
Enter the exponent: 2
Result: 4
Conclusion
And we guided you on how to use the pow() function in Python.
Thank you for checking it out!