Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries


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 below example, 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))

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