Usage and Function Description of pow Function in python

  • 2021-08-17 00:18:57
  • OfStack

Power operation is an applied discipline of Gauguin mathematics, and it is a mathematical operation about power. Multiply with the power of the base, keep the base unchanged, and add exponents. Divide with the power of the base, keep the base unchanged, and subtract exponentially. The power of the power, the base is unchanged, and the exponents are multiplied. It is suitable for the field of accurate calculation.

As a way of accurate calculation, computer contains a lot of power operations. In python, there is a built-in function pow, which represents power operation.

1. The pow () function

Built-in function of Python, which calculates and returns the y power of x.

2. Grammar


pow(x, y, z)

3. Parameters

x--A numeric expression.

y--Numeric expression.

z--Numeric expression.

4. Return value

Returns the value of x y (x to the power of y).

5. Explanation of pow () function

pow (x, y): Represents y power of x.


>>> pow(2,4)
  16
>>>

pow (x, y, z): Represents the remainder of y power of x divided by z.


>>> pow(2,4,5)
  1
>>>

6. Example: pow () returns the exponential value of two numeric values


>>> pow(2,3)
>>> 2**3
>>> pow(2,3,5)
>>> pow(2,3)%5

Built-in function pow () instance


>>> help(pow)
Help on built-in function pow in module __builtin__:
pow(...)
 pow(x, y[, z]) -> number
 With two arguments, equivalent to x**y. With three arguments,
 equivalent to (x**y) % z, but may be more efficient (e.g. for longs).
>>>
>>> pow(3,2) # 3**2
9
>>> pow(3,2,4)# (3**2)%4
1

Related articles: