+1 vote
2 views
in Python by (200 points)

float('nan') results Nan (not a number). It is very easy but how can I check?

1 Answer

+2 votes
by (10.9k points)
edited by

You can use math.isnan() which will return True if the variable is a NAN else False

Syntax-

math.isnan(variable)

Alternatively, another way to test for NaN is comparing the number to itself.

def isNaN(num):

   return num != num

Related questions

0 votes
1 answer
asked Oct 14, 2019 in Python by Sammy (47.8k points)
+1 vote
1 answer
asked Jul 31, 2019 in Python by Aarav (11.5k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...