Open mishgu opened 6 years ago
Let's break it down a bit:
0*[]
means []
, because 2*[x]
means [x,x]
. If you sum([], float("nan"))
, you get the sum of all numbers in []
plus your starting value float("nan")
, which results in nan
. However if you try float("nan") == float("nan")
you always get False
. That's I think because ==
either compares two numbers or two objects with each other (despite being typed float
). Now, because float("nan")
yields not a number, it cannot be equal to any number, not even to itself:
>>> y=float("nan")
>>> y==y
False
In the end, why did you use ==
on not a number in the first place? I don't see where this is a pywat.
When we look at Question 5: zero sum the answer tells "No. This snippet is impossible." So if use my example, that snippet is possible and can I use that example as correct answer
Thanks for the report. But you can't use NaNs. Those are considered "trick" answers for the purpose of the quiz, because NaNs have edge cases that have nothing to do with Python, and it would be unfair to expect people to know them all. This is the first bullet point under the "Details and Scope" section. If you think there's a clearer way to say this, I'm open to it.
So we have that question
if x equal one of
and
that snippet is possible. For ex:
Please correct me if I'm wrong.