# Python math library | isnan() method

Python has `math `library and has many functions regarding it. One such function is `isnan()`. This method is used to check whether a given parameter is a valid number or not.

Syntax : math.isnan(x)

Parameters :
x [Required] : It is any valid python data type or any number.

Returns: Return type is boolean.
-> Returns False if the given parameter is any number(positive or negative)
-> Returns True if given parameter is NaN (Not a Number).

Code #1:

 `# Python3 code to demonstrate  ` `# the working of isnan()  ` `import` `math  ` ` `  `# initializing the value  ` `test_int ``=` `4` `test_neg_int ``=` `-``3` `test_float ``=` `0.00` ` `  `# checking isnan() values  ` `# with different numbers ` `print` `(math.isnan(test_int)) ` `print` `(math.isnan(test_neg_int)) ` `print` `(math.isnan(test_float)) `

Output:

```False
False
False
```

Code #2:

 `# Python3 code to demonstrate  ` `# the working of isnan()  ` `import` `math  ` ` `  `# checking isnan() values  ` `# with inbuilt numbers ` `print` `(math.isnan(math.pi)) ` `print` `(math.isnan(math.e)) ` ` `  ` `  `# checking for NaN value ` `print` `(math.isnan(``float``(``'nan'``))) `

Output:

```False
False
True
```

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.