logo

Question detail

What is the result of this Python function call? ```python def f(n): if n == 0: return 0 return n + f(n - 1) f(3) ```

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

At a glance

MCQ

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

What is the result of this Python function call? ```python def f(n): if n == 0: return 0 return n + f(n - 1) f(3) ```.

  1. A.3
  2. B.5
  3. C.6
  4. D.9

Model answer

What a good answer should say

  • 6

Explanation

Why this works

The calls produce 3 + f(2), then 2 + f(1), then 1 + f(0). The base case returns 0, giving 3 + 2 + 1 + 0 = 6.

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.