+

# Python Math Library | exp () method

Python has a math library and has many functions related to this. One of these functions is exp () . This method is used to compute the degree of e, i.e., e ^ y, or we can say exponential in y. The value of e is approximately 2.71828 ... ..

Syntax: math.exp (y)

Parameters:
y [Required] - It is any valid python number either positive or negative.
Note that if y has value other than number then its return error.

Returns: Returns floating point number by calculating e ^ y.

Code # 1:

 ` # Python3 demo code ` ` # exp () work ` ` import ` ` math `   ` # value initialization ` ` test_int ` ` = ` ` 4 ` ` test_neg_int ` ` = ` ` - ` ` 3 ` ` test_float ` ` = ` ` 0.00 `   ` # checking exp () values ​​` ` # with different numbers ` ` print ` ` (math.exp (test_int)) ` ` print ` ` (math.exp (test_neg_int)) ` ` print ` ` (math.exp (test_float)) `

Exit:

` 54.598150033144236 0.049787068367863944 1.0 `

Code # 2:

 ` # Python3 demo code ` ` # exp () work ` ` import ` ` math `   ` # checking exp () values ​​` ` # with embedded numbers ` ` print ` ` (math.exp (math.pi)) ` ` print ` ` (math.exp (math.e)) `

Output:

` 23.140692632779267 15.154262241479262 `

Code # 3: TypeError

 ` # Python3 demo code ` ` # exp () work ` ` import ` ` math `   ` # line check ` ` print ` (math.exp ( ` "25" ` `)) `

Exit:

` Traceback (most recent call last): File "/home/c7ae4f1bef0ed8c7756b3f55e7d2ce81.py", line 6, in print (math.exp ("25")) TypeError: a float is required `