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

Python math.isnan() Method

Python math.isnan() Method

Python math.isnan() method is used to check whether the given input value is nan (Not a Number) or not. It returns a Boolean value True if the value is nan and False if the value in not.

Syntax:
math.isnan(x)

Parameter Values

Parameter Description
x This is a required parameter. It defines the value to check for NaN.
Here is an example of Python math.isnan() method:

import math
print (math.isnan (56))
print (math.isnan (-45.34))
print (math.isnan (+45.34))
print (math.isnan (math.inf))

Output:
False
False
False
False
Example 2:

import math
print (math.isnan (math.inf))
print (math.isnan (math.nan))
print (math.isnan (float("nan")))
print (math.isnan (float("inf")))
print (math.isnan (float("-inf")))

Output:
False
True
True
False
False

No Sidebar ads