Exam-style question
Try this first
What single value is produced by functools.reduce(lambda total, value: total + value, [4, 7, 2], 0)?.
- A.9
- B.11
- C.13
- D.[4, 7, 2, 0]
Model answer
What a good answer should say
- 13
Explanation
Why this works
reduce repeatedly applies the combining function, starting with 0: ((0 + 4) + 7) + 2 = 13.
Common mistake
No common mistake is linked to this question yet.
