Let’s learn How to calculate the exponential value in Python.

The easiest way to calculate the exponential value in Python is to use the exponentiation operator (**) double asterisk.

my_base = 5 my_exponent = 3 print ("Exponential value equals: ", my_base ** my_exponent) my_base = 5 my_exponent = -3 print ("Exponential value equals: ", my_base ** my_exponent) my_base = -5 my_exponent = 3 print ("Exponential value equals: ", my_base ** my_exponent) my_base = -5 my_exponent = -3 print ("Exponential value equals: ", my_base ** my_exponent)

You can also write in the different way by using the pow function of math module.

import math my_base = 5 my_exponent = 3 print ("Exponential value equals: ", math.pow(my_base, my_exponent)) my_base = 5 my_exponent = -3 print ("Exponential value equals: ", math.pow(my_base, my_exponent)) my_base = -5 my_exponent = 3 print ("Exponential value equals: ", math.pow(my_base, my_exponent)) my_base = -5 my_exponent = -3 print ("Exponential value equals: ", math.pow(my_base, my_exponent))

In case you would like to calculate the exponential value of Euler’s constant number you need to use exp method of math module.

import math my_exponent = 3 print ("Exponential value equals: ", math.exp(my_exponent))