Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Python expm1

by suresh

The Python expm1 math function is to calculate the power of E (Where E is Euler’s number approximately equal to 2.71828) and subtracts One from it. In this section, we discuss how to use expm1 function in Python with example.

The syntax of the expm1 Function in Python Programming Language is

math.expm1(number);

Or we can simply say math.exp(number) – 1. Please refer Python exp function for further reference.

Number: It can be a number or a valid numerical expression.

  • If the number argument is a positive or negative number, the expm1 function returns the output.
  • If the number argument is not a number, expm1 function return TypeError.

Python expm1 Function Example

The Python expm1 Function calculates the power of Euler’s number E and subtracts One from it. In this example, we use expm1 to find the power of e of different data types.

# Python expm1 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('EXPM1() Function on Positive Number = %.2f' %math.expm1(1))
print('EXPM1() Function on Negative Number = %.2f' %math.expm1(-1))

print('EXPM1() Function on Tuple Item = %.2f' %math.expm1(Tup[2]))
print('EXPM1() Function on List Item = %.4f' %math.expm1(Lis[2]))

print('EXPM1() Function on Multiple Number = %.4f' %math.expm1(10 + 20 - 15.65))

print('EXPM1() Function on String Value = ', math.expm1('3'))

Python EXPM1 Function

  1. First, We declared Python List and Python Tuple with some random values.
  2. Within the first two statements, We used the expm1 Function with both the Positive integer and negative integer values as arguments.
  3. Next two statements, We used the expm1 Function on Python Tuple and List items. If you observe the above screenshot, the expm1 function is working perfectly on them.
  4. Next, we tried the expm1 Math function directly on multiple values.
  5. In the Last statement, We used the expm1 Function on the String value. As we said before, it returns TypeError as output.

Placed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File Handling
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python numpy concatenate
  • Python numpy Array shape
  • Python pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python substring
  • Python Programming Examples

Copyright © 2021· All Rights Reserved.
About | Contact | Privacy Policy