Python isinf

The Python isinf function checks whether the given value is an infinite number or not. If it is an infinite number, then the math.isinf returns True otherwise, False.

The syntax of the isinf in Python Programming Language is as

math.isinf(value)

Python isinf example

In this example, we are using the isinf function on both positive and negative numeric and decimal values. We have also used Python math.pi inside this function.

import math
 
print(math.isinf(10))
 
print(math.isinf(0.00))
 
print(math.isinf(-200))
 
print(math.isinf(-4.0002))
 
print(math.isinf(math.pi))
False
False
False
False
False

In this isinf Mathematical function, we are passing the infinity, NaN(not a number) values as the function arguments.

import math
 
print(math.isinf(0/1))
 
print(math.isinf(0.00/1))
 
print(math.isinf(float('NaN')))
 
print(math.isinf(float('inf')))
 
print(math.isinf(float('-inf')))
Python isinf Function 2