logo

Question detail

Explain how parameters allow the following Python subroutine to be reused with different data. Include two example calls and the value printed by each call. ```python def showDifference(first, second): print(first - second) ```

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

Explain how parameters allow the following Python subroutine to be reused with different data. Include two example calls and the value printed by each call. ```python def showDifference(first, second): print(first - second) ```.

Model answer

What a good answer should say

  • The parameters `first` and `second` act as named places for data supplied when the subroutine is called.
  • For example: ```python showDifference(10, 4) ``` prints 6, while: ```python showDifference(20, 7) ``` prints 13.
  • The same subroutine is reused because different arguments can be passed through its interface.

Explanation

Why this works

Parameters separate the subroutine's instructions from the particular data being processed. Each call supplies new argument values, which are used by the same calculation.

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.