The Python frexp function is one of the Python Mathematical Functions 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 section, we discuss how to use frexp function in Python Programming language with example.

The Python frexp function is one of the Python Mathematical Functions 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 section, we discuss how to use frexp function in Python Programming language with example.

frexp() function is one of the Standard math Library function in Python.

It returns mantissa and exponent as a pair (m, e) of a given value x, where mantissa m is a floating point number and e exponent is an integer value. m is a float and e is an integer such that x == m * 2**e exactly.

If x is zero, returns (0.0, 0), otherwise 0.5 <= abs(m) < 1. This is used to “pick apart” the internal representation of a float in a portable way.

```
math.frexp(n)
```

Here `n`

is a number for which we will find mantissa and exponent.

Any valid number (positive or negative).

Returns mantissa and exponent as a pair (m, e) value of a given number x.

```
# app.py
# Importing math library
import math
# Demonstrating working of frexp()
# Using different types of value of x
# When x is positive number
x = 5
print("Pair of mantissa and exponent of ", x, " is: ", math.frexp(x))
# When x is float type number
x = 6.4
print("Pair of mantissa and exponent of ", x, " is: ", math.frexp(x))
# When x is a negative number
x = -32
print("Pair of mantissa and exponent of ", x, " is: ", math.frexp(x))
# Declaring a list
x = [4, 3, 7]
# Using frexp() with the 3rd value of the list
print("Pair of mantissa and exponent of ", x[2], " is: ", math.frexp(x[2]))
# When x is not a number
x = '41'
print("Pair of mantissa and exponent of ", x, " is: ", math.frexp(x))
```

**Output**

```
Pair of mantissa and exponent of 5 is: (0.625, 3)
Pair of mantissa and exponent of 6.4 is: (0.8, 3)
Pair of mantissa and exponent of -32 is: (-0.5, 6)
Pair of mantissa and exponent of 7 is: (0.875, 3)
Traceback (most recent call last):
File "frexp.py", line 27, in <module>
print("Pair of mantissa and exponent of ",x," is: ",math.frexp(x))
TypeError: must be real number, not str
```

In the above code, we have taken different types of values of x and checked the output using the frexp() method. We can see that in each case, an output is in (m,e) pair.

At last, when we have declared value of x as a character, a TypeError is returned.

Use frexp() with Python tuple and list

See the following code in which we have defined Python list and tuple.

```
# app.py
import math
# creating a list
lst = [11, 21.11, 21.19, 30]
# creating a tuple
tpl = (-15.31, -41.31, -11.21, 46.19)
# calculating mantissa and exponent
# of 1st, 3rd elements in list
print(math.frexp(lst[0]))
print(math.frexp(lst[2]))
# calculating mantissa and exponent
# of 2nd, 3rd and 4th elements in tuple
print(math.frexp(tpl[1]))
print(math.frexp(tpl[2]))
print(math.frexp(tpl[3]))
```

**Output**

```
python3 app.py
(0.6875, 4)
(0.6621875, 5)
(-0.64546875, 6)
(-0.700625, 4)
(0.72171875, 6)
```

Python frexp() method is one of the Python Mathematical Functions that is used to return the mantissa and exponent of x, as a pair (m, e) where m is the float value and e is an integer value.

Guide to Python Programming Language

Description

The course will lead you from beginning level to advance in Python Programming Language. You do not need any prior knowledge on Python or any programming language or even programming to join the course and become an expert on the topic.

The course is begin continuously developing by adding lectures regularly.

Please see the Promo and free sample video to get to know more.

Hope you will enjoy it.

Basic knowledge

An Enthusiast Mind

A Computer

Basic Knowledge To Use Computer

Internet Connection

What will you learn

Will Be Expert On Python Programming Language

Build Application On Python Programming Language

Python Programming Tutorials For Beginners

Description

Hello and welcome to brand new series of wiredwiki. In this series i will teach you guys all you need to know about python. This series is designed for beginners but that doesn't means that i will not talk about the advanced stuff as well.

As you may all know by now that my approach of teaching is very simple and straightforward.In this series i will be talking about the all the things you need to know to jump start you python programming skills. This series is designed for noobs who are totally new to programming, so if you don't know any thing about

programming than this is the way to go guys Here is the links to all the videos that i will upload in this whole series.

In this video i will talk about all the basic introduction you need to know about python, which python version to choose, how to install python, how to get around with the interface, how to code your first program. Than we will talk about operators, expressions, numbers, strings, boo leans, lists, dictionaries, tuples and than inputs in python. With

Lots of exercises and more fun stuff, let's get started.

Download free Exercise files.

Dropbox: https://bit.ly/2AW7FYF

Who is the target audience?

First time Python programmers

Students and Teachers

IT pros who want to learn to code

Aspiring data scientists who want to add Python to their tool arsenal

Basic knowledge

Students should be comfortable working in the PC or Mac operating system

What will you learn

know basic programming concept and skill

build 6 text-based application using python

be able to learn other programming languages

be able to build sophisticated system using python in the future

Learn Python Programming

Description

Learn Python Programming

Learn Python Programming and increase your python programming skills with Coder Kovid.

Python is the highest growing programming language in this era. You can use Python to do everything like, web development, software development, cognitive development, machine learning, artificial intelligence, etc. You should learn python programming and increase your skills of programming.

In this course of learn python programming you don't need any prior programming knowledge. Every beginner can start with.

Basic knowledge

No prior knowledge needed to learn this course

What will you learn

Write Basic Syntax of Python Programming

Create Basic Real World Application

Program in a fluent manner

Get Familiar in Programming Environment