The Python EXP function is one of the Python Math function which is used to calculate the power of E, Where E is Euler’s number approximately equal to 2.71828. In this article we will show you, How to use EXP() function in Python Programming language with example.
Syntax of a Python EXP Function
The basic syntax of the EXP Function in Python Programming Language is as shown below:
Number: It can be a number or a valid numerical expression and it represent the exponent value.
- If the number argument is positive or negative number, EXP() function will return the output.
- If the number argument is not a number, EXP() function will return TypeError.
Python EXP Function Example
The Python EXP Function is used to calculate the power of Euler’s number E. In this example, We are going to check the same with different data types and display the output
# Python EXP Function import math Tup = (1.98, 20.26, 13.05, -40.95 , 0.45) # Tuple Declaration Lis = [-10.98, 3.65, -9.59, -4.15 , 5.97] # List Declaration print('EXP() Function on Positive Number = %.2f' %math.exp(1)) print('EXP() Function on Negative Number = %.2f' %math.exp(-1)) print('EXP() Function on Tuple Item = %.2f' %math.exp(Tup)) print('EXP() Function on List Item = %.4f' %math.exp(Lis)) print('EXP() Function on Multiple Number = %.4f' %math.exp(10 + 20 - 15.65)) print('EXP() Function on String Number = ', math.exp('Python'))
- At the beginning, We declared Python List and Tuple with some random values.
- Within first two statements, We used the EXP() Function with both the Positive integer and negative integer values as arguments.
- Next two statements, We used the EXP() Function on Python Tuple and List items. If you observe the above screenshot, EXP() function is working perfectly on them.
- Next, We tried EXP() Function directly on multiple values.
- In the Last statement, We used the EXP() Function on String value. As we said before, this will return TypeError as output.
Thank You for Visiting Our Blog