logo

AQA A-Level Computer Science practice

Explain the difference between a subroutine that returns a value and a subroutine that only displays a value. Include a Python 3 example showing how a returned value can be used in the calling routine.

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

Explain the difference between a subroutine that returns a value and a subroutine that only displays a value. Include a Python 3 example showing how a returned value can be used in the calling routine.

Answer and explanation

Concise answer

A subroutine that returns a value sends that value back to the calling routine, where it can be assigned to a variable or used in an expression.

Why this is correct

The key distinction is that return transfers a value to the caller, while displaying a value only produces output. In the example, square(5) returns 25 and the calling routine stores that value in answer, allowing it to be used later.

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