The Python FREXP function is one of the Python Mathematical Function which is used to return the mantissa and exponent of x, as pair (m, e) where m is a float value and e is an integer value. In this article we will show you, How to use FREXP() function in Python Programming language with example.

## Syntax of a Python FREXP Function

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

1 |
Math.frexp(Number); |

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

- If the
*number*argument is positive or negative number, FREXP() function will return the mantissa and exponent of x, as pair (m, e). - If the
*number*argument is not a number, FREXP() function will return**TypeError**

**TIP:** By doing the reverse approach we can easily find the ** Number** value and the formula behind this is: Number = m * 2**e. Here m is the first argument and e is the second argument.

### Python FREXP Function Example

The Python FREXP function is used to is used to return the mantissa and exponent of x, as pair (m, e). In this example, We are going to return the same for different data types and display the output

**PYTHON CODE**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# Python FREXP Function import math Tup = (10.98, 20.26, -30.05, -40.95 , 50.85) # Tuple Declaration Lis = [-10.98, 32.65, -39.29, -42.15 , 39.97] # List Declaration print('FREXP() Function on Positive Number = ', math.frexp(2)) print('FREXP() Function on Negative Decimal = ', math.frexp(-3)) print('FREXP() Function on Positive Decimal = ', math.frexp(4.5)) print('FREXP() Function on Negative Decimal = ', math.frexp(-6.5)) print('FREXP() Function on Tuple Item = ', math.frexp(Tup[2])) print('FREXP() Function on Tuple Item = ', math.frexp(Tup[4])) print('FREXP() Function on List Item = ', math.frexp(Lis[2])) print('FREXP() Function on List Item = ', math.frexp(Lis[4])) print('FREXP() Function on Multiple Number = ', math.frexp(10 + 20 - 40.6578)) print('FREXP() Function on String Value = ', math.frexp('2.95')) |

**OUTPUT**

**ANALYSIS**

At the beginning, We declared Python List and Tuple with some random values.

1 2 |
Tup = (10.98, 20.26, -30.05, -40.95 , 50.85) # Tuple Declaration Lis = [-10.98, 32.65, -39.29, -42.15 , 39.97] # List Declaration |

First two statements, We used the FREXP() Function directly on both the Positive and Negative Numbers.

1 2 |
print('FREXP() Function on Positive Number = ', math.frexp(2)) print('FREXP() Function on Negative Decimal = ', math.frexp(-3)) |

From the above screenshot you can observe that, math.frexp(2) is returning output as (0.5, 2). It means *m = 0.5* and *e = 2. *Let us do the reverse approach so that you can understand it well.

As we said before, Number = m * 2**e (2 power e). Here we given the Number argument as 2

Number = 0.5 * 2**2

Number = 0.5 * 4 = 2

Hope you understood 🙂

- Next two statements, We used the FREXP() Function directly on both the Positive decimals and negative decimals.
- Next four statements, We used the FREXP() Function on Python Tuple and List items. If you observe the above screenshot, FREXP() function is working perfectly on them.
- Next statement, We tried FREXP() Function directly on multiple values
- Last, We tried FREXP() Function on String value. As we said before, this will return
as output**TypeError**

Thank You for Visiting Our Blog

## Share your Feedback, or Code!!