Nan-reflexivity
We'll cover the following...
Let’s see what Python thinks about NaN and infinity.
1.
What do you think about these assignments?
Press + to interact
a = float('inf')b = float('nan')c = float('-iNf') # These strings are case-insensitived = float('nan')
Let’s observe some behaviors in the terminal below:
2.
Let’s explore further.
Press + to interact
x = float('nan')y = x / xprint(y is y) # identity holdsprint(y == y) # equality fails of yprint([y] == [y]) # but the equality succeeds for the list containing y
Explanation
-
'inf'</
...