How can I represent an infinite number in Python?

PythonServer Side ProgrammingProgramming

A number equivalent to infinity can be assigned to a float variable by putting 'inf' as argument to float() function

>>> a=float('inf')
>>> a
inf

It is also possible to achieve same effect by assigning inf constant in math module

>>> import math
>>> a=math.inf
>>> a
inf
Published on 05-Mar-2018 19:11:11