Code: Alles auswählen
>>> a = float("NaN")
>>> if a == float("NaN"):
print(True)
>>> if float("NaN") == float("NaN"):
print("Ja")
>>> import math
>>> math.isnan(a)
True
Code: Alles auswählen
>>> a = float("NaN")
>>> if a == float("NaN"):
print(True)
>>> if float("NaN") == float("NaN"):
print("Ja")
>>> import math
>>> math.isnan(a)
True
Code: Alles auswählen
values = [8, 4, 6, 4]
mw = [x, 6, 5, 5]
Code: Alles auswählen
>>> a = [None, 4, 4, 4, 4]
>>> print(sum(a) / len(a))
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
print(sum(a) / len(a))
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
>>> a = [float("NaN"), 4, 4, 4, 4]
>>> print(sum(a) / len(a))
nan
Code: Alles auswählen
>>> from itertools import tee
>>> def pairwise(seq):
... a, b = tee(seq)
... next(b)
... return zip(a, b)
...
>>> list(pairwise([1, 2, 3, 4]))
[(1, 2), (2, 3), (3, 4)]
>>> [(x + y) // 2 for x, y in pairwise([8, 4, 6, 4])]
[6, 5, 5]