原文链接:https://github.com/cosmologicon/pywat/blob/master/quiz-answers.md
Question 1: min
of two elements
Yes. This snippet is possible.
>>> x, y = {0}, {1}
>>> min(x, y) == min(y, x)
False
Question 2: size of sets and lists
No. This snippet is impossible.
>>> x = ???
>>> len(set(list(x))) == len(list(set(x)))
False
Question 3: type
vs map
Yes. This snippet is possible.
>>> x, s = True, {1}
>>> s.add(x)
>>> type(x) in map(type, s)
False
Question 4: zip
vs comparison
Yes. This snippet is possible.
>>> x, y = [], [0]
>>> x < y and all(a >= b for a, b in zip(x, y))
True
Question 5: zero sum
No. This snippet is impossible.
>>> x, y = ???
>>> sum(0 * x, y) == y
False
Question 6: argument expansion
Yes. This snippet is possible.
>>> x = [[0]]
>>> min(x) == min(*x)
False
Question 7: Associative multiplication
Yes. This snippet is possible.
>>> x, y, z = [0], -1, -1
>>> x * (y * z) == (x * y) * z
False
Question 8: max
vs in
Yes. This snippet is possible.
>>> x, y = "aa", "aa"
>>> y > max(x) and y in x
True
Question 9: any
vs addition
No. This snippet is impossible.
>>> x, y = ???
>>> any(x) and not any(x + y)
True
Question 10: count
vs len
Yes. This snippet is possible.
>>> x, y = "a", ""
>>> x.count(y) <= len(x)
False
Question 11: all
vs filter
No. This snippet is impossible.
>>> x = ???
>>> all(filter(None, x))
False
Question 12: max
vs slice
No. This snippet is impossible.
>>> x, a, b, c = ???
>>> max(x) < max(x[a:b:c])
True