isnan()
function exists in Standard math Library of Python Programming Language and is used to determine whether a given parameter is a valid number or not.
If given number x
as parameter is a valid Python number (Positive or Negative), isnan()
function returns False
.
If given number x
as a parameter is NaN (Not a Number), isnan()
returns True
.
Syntax of isnan()
in Python
The syntax of
isnan()
function in python is:math.isnan( x )
Parameters of Python isnan()
Function
x
is any valid Python data type. This parameter is required.
Python isnan()
Function Compatibility
Python 2.x – Yes
Python 3.x – Yes
Python 3.x – Yes
Return Value of Python isnan()
Function
The return value of
isnan()
function is either True or False.
Python isnan()
Function Example
# import math library import math print(math.isnan(2)) print(math.isnan(0.0)) print(math.isnan(0.007)) print(math.isnan(-25)) print(math.isnan(math.pi))
Output of Python isnan()
function
False
False
False
False
False