ProceduralOCR J277
DashboardCoursePracticeReviewProgressGlossary
Saved on this deviceContinue learning

Procedural · OCR J277 programming practice

Progress stays in this browser unless you export it.

Course/Procedures & functions/Using parameters
J277 · 2.2.3

Unit 9 · Lesson 2

Using parameters

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Define and call a procedure that uses every value supplied through its parameters.

Parameters make one procedure useful with many values. They are named in the definition and receive the values supplied by each call. The body should use those parameters directly. If it asks for replacement input, it throws away the caller's data and defeats the purpose of passing parameters.

Parameter

A named value received by a sub-program when it is called.

Parameter list

The parameter names written inside the brackets of a sub-program definition.

Call

An instruction that runs a sub-program and supplies any required values.

Reuse

Calling the same sub-program with different values instead of copying its code.

Keep these in mind

  • Values in a call match parameters by position.
  • A string supplied directly in a call needs quotation marks.
  • The body must use its parameters rather than overwrite them.
  • Parameters are local to the sub-program.
  • Clear parameter names make the sub-program easier to understand.

Learning objective

Define and call a procedure that uses every value supplied through its parameters.

Exam tip

When a question gives a procedure heading such as SaveLogs(data, filename), use data and filename inside the body; do not ask the user for them again.

Common mistake

Do not write name = input() inside greet(name). That overwrites the parameter that the call already supplied.

PreviousNext