logo

Question detail

Which function has a general case that moves its argument towards the base case?

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

Which function has a general case that moves its argument towards the base case?.

  1. A.```python def count(n): if n == 0: return count(n - 1) ```
  2. B.```python def count(n): if n == 0: return count(n + 1) ```
  3. C.```python def count(n): return count(n) ```
  4. D.```python def count(n): if n == 0: return count(10) ```

Model answer

What a good answer should say

  • ```python def count(n): if n == 0: return count(n - 1) ```

Explanation

Why this works

The function stops when n is 0 and decreases n on each general-case call, so the calls move towards the base case.

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.