Easy Tutorial
❮ Python Func Chr Python Os Lchflags ❯

Python math.inf Constant

Python math Module

Python math.inf represents a floating-point positive infinity, while negative infinity is represented by -math.inf.

math.inf is equivalent to the output of float('inf').

Syntax

The syntax for the math.inf constant is as follows:

math.inf

Return Value

Returns a floating-point number representing positive infinity.

Example

The following example returns positive and negative infinity:

Example

# Import math package
import math

# Output positive infinity
print(math.inf)

# Output negative infinity
print(-math.inf)

Output result:

inf
-inf

Python math Module

❮ Python Func Chr Python Os Lchflags ❯