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]
Answer and explanation
Concise answer
13
Why this is correct
reduce repeatedly applies the combining function, starting with 0: ((0 + 4) + 7) + 2 = 13.
Use the concise answer above for a quick check, then reveal the full model answer and detailed explanation.
Common mistake
No common mistake is linked to this question yet.
