×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

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

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.