Python isfinite

The Python isfinite function check whether the given value is a finite number (Not an Infinity and Not a Number) or not. If it is an infinite number or Not a Number, then isfinite returns False otherwise, True.

The syntax of the isfinite in Python Programming Language is

math.isfinite(value)

Python isfinite example

In this example, we are using the isfinite function on both positive & negative numeric and decimal values. We have also used Python math.pi as the argument of this Mathematical function.

import math
 
print(math.isfinite(1))
 
print(math.isfinite(0.00))
 
print(math.isfinite(-10))
 
print(math.isfinite(-10.0052))
 
print(math.isfinite(math.pi))

isfinite output

True
True
True
True
True

In this isfinite example, we are passing the infinity and not a number values as the function arguments.

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