logo

AQA A-Level Computer Science practice

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

Try the question first, then check the answer and practise the same topic again.

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) ```

Answer and explanation

Concise answer

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

Why this is correct

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

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.

Related flashcards

No flashcards are published for this page yet.

Related practice questions