# How to Represent an Infinite Number in Python?

To represent an infinite number you need to define a specific rule. For example, the infinite number in the examples of this article is represented as a string developed in the Python programming language. If you have any questions or suggestions kindly use the comment section and help us build a better article.

### python infinite value

By Ugliest Unicorn on Mar 26, 2020
``````test = float("inf")

In Python 3.5, you can do:

import math
test = math.inf``````

5

### infinity in python

By Aggressive Addax on Jan 31, 2021
``````# Defining a positive infinite integer
positive_infnity = float('inf')
print('Positive Infinity: ', positive_infnity)

# Defining a negative infinite integer
negative_infnity = float('-inf')
print('Negative Infinity: ', negative_infnity)``````

2

### python math negative infinity

By Kodi4444 on Dec 29, 2020
``````# Import math Library
import math

# Print the positive infinity
print (math.inf)

# Print the negative infinity
print (-math.inf)``````

2

### python infinity

By African Red Eyed Bulbul on Feb 20, 2020
``test = float("inf")``

Source: stackoverflow.com

4

### python set negative infinity

By Dentedghost on Jan 12, 2021
``````# Define Negative infinity number
ntive_inf = float('-inf')
print('Negative Infinity: ',ntive_inf)``````

Source: www.stechies.com

0

### float inf in python

By Strange Skipper on Jun 27, 2020
``````float('inf')
float('-inf')``````

2

When we are trying to represent infinite numbers in python, we use isinf() function because it returns true when the value is infinite.

### Python answers related to "python infinity"

View All Python queries

### Browse Other Code Languages 