Python math - isinf() Function
The Python math.isinf() function is used to check if the argument is positive or negative infinity. It returns true if the argument is positive or negative infinity, else returns false.
Syntax
math.isinf(x)
Parameters
x |
Required. Specify the value. |
Return Value
Returns true if the argument is positive or negative infinity, else returns false.
Example:
In the example below, isinf() function is used to check if the argument is positive or negative infinity.
import math print(math.isinf(2)) print(math.isinf(-2)) print(math.isinf(1.5),"\n") print(math.isinf(float("nan"))) print(math.isinf(float("inf"))) print(math.isinf(float("-inf")))
The output of the above code will be:
False False False False True True
❮ Python Math Module