logo

Question detail

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, check the answer, then read the explanation to understand the curriculum point.

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.

Model answer

What a good answer should say

  • ```python def calculateArea(width, height): return width * height area = calculateArea(8, 5) ``` The value returned is 40.

Explanation

Why this works

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.

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.