The math.isnan() function is used to determine whether or not a given value is Not a Number (NaN).

Syntax:
math.isnan(x)

Where, x is the value which we want to check whether it is Not a Number.

The return value of this function will be either True or False, depending on whether or not the given argument is a NaN.

What do we mean by 'Not Number'?

Not a Number (NaN) is a special value used to represent any computation result which is undefined or meaningless. It is also known as an undefined number.  This value can be returned when the result of a mathematical operation is undefined.For example

  1. Division by zero, such as 1/0.
  2. Calculating the square root of a negative number
  3. Attempting to get logarithm of a negative number.

In Python, NaN is represented as float('nan')

ExampleEdit & Run
import math

print(math.isnan(float('nan')))
print(math.isnan(float('-nan')))
print(math.isnan(math.nan))
print(math.isnan(-math.nan))
Output:
TrueTrueTrueTrue[Finished in 0.010698968078941107s]
ExampleEdit & Run
import math

print(math.isnan(0))
print(math.isnan(10000))
print(math.isnan(-0.111))
print(math.isnan(math.pi))
print(math.isnan(math.inf))
print(math.isnan(math.e))
Output:
FalseFalseFalseFalseFalseFalse[Finished in 0.010169684886932373s]