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 Python math.isinf returns True otherwise, False, and the syntax of it is

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 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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.