Home >>Python math Module >Python math.isfinite() Method

Python math.isfinite() Method

Python math.isfinite() Method

Python math.isfinite() method in python Is used to returns a Boolean value means True if number neither an infinity nor a NaN (Not A Number), else it returns False and, it only accepts a number (float/ integer, infinite or NaN, finite).

Syntax:
math.isfinite(x)

Parameter Values

Parameter Description
X It is required a value to check whether it is finite or not
Here is an Example of Python math.isfinite() Method:

import math
print (math.isfinite (34))
print (math.isfinite (-12.56))
print (math.isfinite (+56.12))
print (math.isfinite (float("nan")))
print (math.isfinite (float("inf")))
print (math.isfinite (math.inf))
print (math.isfinite (float("-inf")))
print (math.isfinite (-math.inf))

Output:
True
True
True
False
False
False
False
False
Example 2:

import math
print(math.isfinite(0))
print(math.isfinite(40))
print(math.isfinite(45.13))
print(math.isfinite(4.0))
print(math.isfinite(float('inf')))
print(math.isfinite(float('-inf')))
print(math.isfinite(float('nan')))

Output:
True
True
True
True
False
False
False

No Sidebar ads