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


The Python Math isfinite() function is used to check if the argument is a finite number or not. It returns true if the argument is neither an infinity nor a NaN, else returns false.

Syntax

isfinite(x)   

Parameters

x Required. Specify the value.

Return Value

Returns true if the argument is neither an infinity nor a NaN, else returns false.

Example:

In the below example, isfinite() function is used to check if the argument is a finite number or not.

import math

print(math.isfinite(2))
print(math.isfinite(-2))
print(math.isfinite(1.5))

print(math.isfinite(float("nan")))
print(math.isfinite(float("inf")))
print(math.isfinite(float("-inf")))

The output of the above code will be:

True
True
True

False
False
False

❮ Python Math Module