Python math.isnan() Method
Example
Check whether a value is NaN or not:
# Import math Library
import math
# Check whether some values are NaN
or not
print (math.isnan (56))
print
(math.isnan (-45.34))
print (math.isnan (+45.34))
print (math.isnan
(math.inf))
print (math.isnan (float("nan")))
print (math.isnan
(float("inf")))
print (math.isnan (float("-inf")))
print (math.isnan
(math.nan))
Try it Yourself »
Definition and Usage
The math.isnan()
method checks whether a value is
nan (Not a Number), or not. This method returns a Boolean value: True
if the value is nan, otherwise False
Syntax
math.isnan(x)
Parameter Values
Parameter | Description |
---|---|
x | Required. The value to check for NaN |
Technical Details
Return Value: | A bool value, True if the value is nan, otherwise False |
---|---|
Python Version: | 3.5 |