logo

AQA A-Level Computer Science practice

Write a Python subroutine called `calculateArea` with an interface that accepts `width` and `height` as parameters. It should calculate and return the area of a rectangle. Then show a call that passes 8 and 5 to the subroutine, and state the value returned.

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

At a glance

Question

Type

practice

Style

Topic

Programming

Exam-style question

Try this first

Write a Python subroutine called `calculateArea` with an interface that accepts `width` and `height` as parameters. It should calculate and return the area of a rectangle. Then show a call that passes 8 and 5 to the subroutine, and state the value returned.

Answer and explanation

Concise answer

```python def calculateArea(width, height): return width * height

Why this is correct

The interface is the subroutine name together with its two parameters, `width` and `height`. The call passes 8 to `width` and 5 to `height`. The subroutine multiplies these values and returns 40.

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