×

### Python pow() Function in Linux - Step by step Guide ?

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.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Python functions queries.

In this context, we shall look into how to use the pow() function in Python in Linux.

#### More about pow() function in Python

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.

It's syntax is given below:

`pow(x, y, z)`

pow() function Parameter Values:

• y: exponent (required)
• z: modulus (optional)

Hence,

• pow(x, y) is equal to xy.
• pow(x, y, z) is equal to xy % z.

#### Examples of using Python pow() Function

1. Take a look at the below pow() functions:

`x = pow(2, 4)print(x)`

The Output will be :

`16`

2. Basic pow() function:

`x = pow(3, 3)print(x)`

The Output will be:

`27`

3. pow() with three argument:

`x = pow(2, 4, 10)print(x)`

It's output will give:

`6`

4. 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 will give:

`Enter the radix: 2Enter the exponent: 2Result: 4`

5. pow() with three arguments (x**y) % z":

`x = 7y = 2z = 5print(pow(x, y, z))    # 4`

The Output will be:

`4`

Here, 7 powered by 2 equals 49. Then, 49 modulus 5 equals 4.

#### Conclusion

This article covers how to use the Python pow() function. In fact, the pow() function returns the value of x to the power of y (xy). If a third parameter is present, it returns x to the power of y, modulus z.