Exponentiation Operator (**)
Exponentiation Operator
Python Exponentiation Operator takes two operands, one on the left and other on the right, and computes the power of left operand (base) raised to the right operand (exponent).
The symbol used for Python Exponentiation operator is **
.
Syntax
Following is the syntax of Exponentiation Operator in Python.
result = operand_1 ** operand_2
where operand_1
and operand_2
are numbers and the result is the operand_1
raised to the exponent of operand_2
.
Example 1: Exponentiation of Integers
In this example, we shall take two integers, find the power of the first integer raised to the exponent of another, and print the result.
Python Program
a = 14
b = 5
result = a ** b
print('Result :', result)
Output
Result : 537824
Now, let us take negative exponent and find the result.
Python Program
a = 14
b = -5
result = a ** b
print('Result :', result)
Output
Result : 1.8593443208187064e-06
Example 2: Exponentiation of Floating Point Numbers
We can compute the exponent for floating point numbers. In the following example, we initialize two floating point numbers, and find the exponent.
Python Program
a = 3.14
b = 4.1
result = a ** b
print('Result :', result)
Output
Result : 108.99625018584567
Summary
In this tutorial of Python Examples, we learned what Python Exponentiation Operator is, how to use it to find the power of a base number raised to the exponent.