Easy Tutorial
❮ Python Att List Sort Python Math ❯

Python3 pow() Function

Python3 Numbers


Description

The pow() method returns x.


Syntax

Here is the syntax for the pow() method in the math module:

import math

math.pow(x, y)

The built-in pow() method:

pow(x, y[, z])

The function computes x to the power of y, and if z is present, it then takes the result modulo z, equivalent to pow(x, y) % z.

Note: When pow() is called directly, the built-in method treats the arguments as integers, whereas the math module converts the arguments to floats.


Parameters


Return Value


Example

Below are examples demonstrating the use of the pow() method:

#!/usr/bin/python3
import math  # Import the math module

print("math.pow(100, 2) : ", math.pow(100, 2))
# Using the built-in method to see the difference in output
print("pow(100, 2) : ", pow(100, 2))
print("math.pow(100, -2) : ", math.pow(100, -2))
print("math.pow(2, 4) : ", math.pow(2, 4))
print("math.pow(3, 0) : ", math.pow(3, 0))

The output of the above examples is:

math.pow(100, 2) :  10000.0
pow(100, 2) :  10000
math.pow(100, -2) :  0.0001
math.pow(2, 4) :  16.0
math.pow(3, 0) :  1.0

Python3 Numbers

❮ Python Att List Sort Python Math ❯