# math.inf constant with example in Python

Python math.inf constant: Here, we are going to learn about the math.inf constant of math module with example in Python.
Submitted by IncludeHelp, on April 19, 2019

## Python math.inf constant

math.inf constant is a predefined constant, which is defined in the math module, it returns a floating-point positive infinity (which is equivalent to float('inf')).

-math.inf can be used to find floating-point negative infinity (which is equivalent to float('-inf')).

Note: math.inf constant is available from Python 3.5

Syntax of math.inf constant:

```    math.inf
```

Return value: float – that is the value of positive infinity.

Example:

```    Input:
print(math.inf)

Output:
inf
```

### Python code to demonstrate example of math.inf constant

```# python code to demonstrate example of
# math.inf constant

# importing math module
import math

# printing value of infinity
print("value of positive infinity = ", math.inf)
print("value of negative infinity = ", -math.inf)
```

Output

```value of positive infinity = inf
value of negative infinity = -inf
```

Reference: Python math library

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates