⊕
⊖
Contents
Python math.isnan()
math.isnan(x) function returns True if x is NaN (Not a Number), and False otherwise.
Syntax
The syntax to call isnan() function is
math.isnan(x)
where
Parameter | Required | Description |
---|---|---|
x | Yes | A value. |
Examples
1. Check if value in x is math.nan
Assign x with NaN value, and programmatically check if x is NaN value, using math.isnan().
Python Program
import math
x = math.nan
result = math.isnan(x)
print('isnan(x) :', result)
Run Code CopyOutput
isnan(x) : True
2. Check if integer value 8 is math.nan
Assign x with some value, like 8, and programmatically check if x is NaN, using math.isnan().
Output
isnan(x) : False
Summary
In this Python Math tutorial, we learned the syntax of, and examples for math.isnan() function.
⫷ Previous Topic Python Math isinf()
Next Topic ⫸ Python Math isqrt()