logo

Question detail

What single value is produced by functools.reduce(lambda total, value: total + value, [4, 7, 2], 0)?

Try the question, check the answer, then read the explanation to understand the curriculum point.

At a glance

MCQ

Type

practice

Style

Topic

Writing functional programs

Exam-style question

Try this first

What single value is produced by functools.reduce(lambda total, value: total + value, [4, 7, 2], 0)?.

  1. A.9
  2. B.11
  3. C.13
  4. 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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions

No questions are published for this page yet.