The Python LDEXP function is one of the Python Math function which is used to return * x * (2**i). *This is also called as inverse of Python FREXP function. In this article we will show you, How to use LDEXP() function in Python Programming language with example.

## Syntax of a Python LDEXP Function

The basic syntax of the LDEXP Function in Python Programming Language is as shown below:

Math.ldexp(x, i);

**X:**Please specify the X value here.**i:**Please specify the i value here.

For example, if **x** = 2 and **i** = 3 then, Math.ldexp(2, 3) = 16. This is because, the formula behind this function is **x * (2**i)**

Output = 2 * (2**3)

Output = 2 * (8)

so, output is 16

**NOTE: **If the *X value* or i* value* argument is not a number, LDEXP() function will return * TypeError*.

### Python LDEXP Function Example

The Python LDEXP function is used to return * x * (2**i)*. In this example, We are going to find the same of different data types and display the output

**PYTHON CODE**

# Python LDEXP Function import math Tup = (1.50, 2.26, -3.05, -4.95 , 5.85) # Tuple Declaration Lis = [-1.98, 2.65, -9.29, -4.15 , 9.97] # List Declaration print('LDEXP() Function on Positive Number = %.2f' %math.ldexp(2, 3)) print('LDEXP() Function on Negative Number = %.2f' %math.ldexp(-3, 2)) print('LDEXP() Function on Positive Decimal = %.2f' %math.ldexp(4.5, 2)) print('LDEXP() Function on Negative Decimal = %.2f' %math.ldexp(-6.5, 3)) print('LDEXP() Function on Tuple Item = %.2f' %math.ldexp(Tup[2], 3)) print('LDEXP() Function on Tuple Item = %.2f' %math.ldexp(Tup[4], 3)) print('LDEXP() Function on List Item = %.2f' %math.ldexp(Lis[2], 4)) print('LDEXP() Function on List Item = %.2f' %math.ldexp(Lis[4], 4)) print('LDEXP() Function on Multiple Number = %.2f' %math.ldexp(1 + 2 - 9, 2)) print('LDEXP() Function on String Value = ', math.ldexp('2.95', 2))

**OUTPUT**

**ANALYSIS**

- At the beginning, We declared Python List and Tuple with some random values.
- Within the first two statements, We passed both the Positive integer and negative integer as the LDEXP() Function arguments. From the above screenshot you can observe that, LDEXP() Function is returning output.
- Within the next two statements, We passed both the Positive and negative decimal values as the LDEXP() Function arguments. From the above screenshot you can observe that, LDEXP() Function is returning output.
- Next four statements, We used the Python Tuple and List items as first arguments and Positive and negative decimal values as second argument for LDEXP() Function. If you observe the above screenshot, LDEXP() function is working perfectly on them.
- Next statement, We assigned multiple values as the first arguments and the LDEXP() Function worked without any issue.
- Last, We tried LDEXP() Function on String value. As we said before, this will return
as output**TypeError**

Thank You for Visiting Our Blog