How to calculate exponential of ex in Python
To calculate the exponential ex in the python language, use the exp () function of the math library.
math.exp(x)
The parameter x is the exponent of the base of natural logarithms (e=2.718281...).
The exp() function returns the exponential of the real number x.
The output (y) is a value from 0 to + ∞. If x = 0 the output is equal to y = 1.
Nota. The exp() function is contained in the math library. To use it, you need to import it into the interpreter with the import or from import statement.
Examples
Example
This script calculates the exponential of 1
import math
math.exp(1)
The output of the function is the base of natural logarithms.
2.718281828459045
Example 2
This script calculates the exponential of zero
from math import exp
exp(0)
The output of the function is
1.0
Example 3
This script calculates the exponential of -1
import math
math.exp(-1)
The output of the function is
0.36787944117144233