The cmath.isnan() function checks if the input argument is a NaN (Not a Number) value. NaN is a special floating-point value indicating that the result of a computation is undefined, unrepresentable, or not a number.

cmath.isnan(x)
x The value(real or complex) to be tested. If the input value is a real number, it is first converted to a complex number before the operation.

The function returns True if is a NaN , False otherwise.

import cmath

print(cmath.isnan(5))
print(cmath.isnan(float('nan')))
print(cmath.isnan(complex('nan')))
print(cmath.isnan(cmath.nan))