There can be positive infinity and negative infinity in python represented by Inf and -Inf. Positive infinity which is greatest of all numbers and negative infinity is least of all numbers.
Program to demonstrate infinity:
# Positive Infinity
p_infinity = float('Inf')
if 99999999999999 > p_infinity:
print("The number is greater than Infinity!")
else:
print("Infinity is greatest")
# Negative Infinity
n_infinity = float('-Inf')
if -99999999999999 < n_infinity:
print("The number is lesser than Negative Infinity!")
else:
print("Negative Infinity is least")
Output:
Infinity is greatest
Negative Infinity is least
0 Comment(s)