The math.exp() is used to calculate the exponential of a given number, specifically the value of e raised to the power of that number.
The value of e is approximately equal to 2.71828.
Syntax
import math
math.exp(num)
Parameter
num(required): The exponent to which e is raised.
Return Value
Returns a float value representing e raised to the power of num
Returns a TypeError if the given input is not a number.
Visual Representation
Example 1: How to Use math.exp() Method
import math
print(math.exp(1))
print(math.exp(5))
print(math.exp(-5))
print(math.exp(3.5))
Output
2.718281828459045
148.4131591025766
0.006737946999085467
33.11545195869231
Example 2 : Passing non-numeric as an argument
import math
print(math.exp('5'))
Output
TypeError: must be real number, not str