Just wondering over here, what is the point of having a variable store an infinite value in a program? Is there any actual use and is there any case where it would be prefer
float('inf')
As stated in answer above, float('inf') is used for setting a variable with an infinitely large value.
In simple words, it sets the value as +ve infinty.
ALTERNATIVELY, we can make use of the following statement,
import sys
least_value = sys.maxsize
The sys.maxsize is more commonly used, for setting large value initially. When our aim is to find the least value from given set of values.
Also, in case if we want to find largest value from given set of values. We can use the following.
import sys
greatest_value = -sys.maxsize - 1
# logic for comparing with rest of values
The -sys.maxsize - 1 is used for setting initial value as -ve infinity.