Scripting

Python pow() Function 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.

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:

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()

x = int(input())

print("Enter the exponent: ")

y = int(input())

power = pow(x,y)

print("Result:",power)

Output: