less than 1 minute read

#Infinity Infinity in python can be represented in multiple ways. Positive infinity number is greatest, and the negative infinity number is the smallest of all numbers.

import math

# Positive infinity
ptive_inf = math.inf
print('Positive Infinity: ',ptive_inf)

# Negative infinity
ntive_inf = -math.inf
print('Negative Infinity: ',ntive_inf)

Or

# Define Positive infinity number
ptive_inf = float('inf')
print('Positive Infinity: ',ptive_inf)

# Define Negative infinity number
ntive_inf = float('-inf')
print('Negative Infinity: ',ntive_inf)

More info here

Leave a comment