# Python math module constants with examples

List of python math module constants: Here, we are going to learn about the math module constants with examples.
Submitted by IncludeHelp, on April 19, 2019

## Python math module constants

In the math module, there are some of the defined constants that can be used for various mathematical operations, these are the mathematical constants and returns their values equivalent to their standard defined values.

In python programming language, there are following math module constants.

## List of constants of math module/library

Sr. Keyword Description
1 math.pi It returns the value of mathematics constant PI (π), the value is 3.141592...
2 math.e It returns the value of mathematical constant e, the value is 2.718281...
3 math.tau It returns the value of mathematical constant TAU (τ), the value is 6.283185...
4 math.inf It returns the floating-point positive infinity, -math.inf is used to get the floating-point negative infinity.
5 math.nan It returns the floating-point nan (Not a Number), the value is nan.

### Python code to demonstrate example of math module constants

In this example, we are printing the value of all constants of python math module.

```# python code to demonstrate example of
# math module constants

# importing math module
import math

# printing value of PI
print("value of pi = ", math.pi)

# printing value of e
print("value of e = ", math.e)

# printing value of tau
print("value of tau = ", math.tau)

# printing value of infinity
print("value of +ve inf = ", math.inf)
print("value of -ve inf = ", -math.inf)

# printing value of nan
print("value of nan = ", math.nan)
```

Output

```value of pi = 3.141592653589793
value of e = 2.718281828459045
value of tau = 6.283185307179586
value of +ve inf = inf
value of -ve inf = -inf
value of nan = nan
```

Preparation

What's New

Top Interview Coding Problems/Challenges!