Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create math-frexp.md #5214

Closed
wants to merge 9 commits into from
Closed
56 changes: 56 additions & 0 deletions content/python/concepts/math-module/terms/math-frexp/math-frexp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
Title: 'math.frexp()'
Description: 'Returns mantissa and exponent as a pair (m, e) value of a given number x.'
Subjects:
- 'Computer Science'
- 'Data Science'
Tags:
- 'Arithmetic'
- 'Functions'
CatalogContent:
- 'learn-python-3'
- 'paths/computer-science'
---

The **`math.frexp()`** [function](https://www.codecademy.com/resources/docs/python/functions) in Python returns mantissa and exponent as a pair _(m, e)_ value of a given number `x`.

## Syntax

```pseudo
math.frexp(x)
```

- `x`: A valid number whose mantissa and exponent are returned.

## Example

Use `math.frexp()` to return the mantissa and exponent of 10:

```py
import math

mantissa, exponent = math.frexp(10)

print("Mantissa of 10: ", mantissa)
print("Exponent of 10: ", exponent)
```

The above code gives the following output:

```shell
Mantissa of 10: 0.625
Exponent of 10: 4
```

## Codebyte Example

Run the following codes for better understanding:

```codebyte/python
import math
print(math.frexp(0))
print(math.frexp(1))
print(math.frexp(10))
print(math.frexp(100))
print(math.frexp(50))
```
Loading