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/Defining and calling procedures
J277 · 2.2.3

Unit 9 · Lesson 1

Defining and calling procedures

Lesson progress0 / 7

Build the idea

Start with the concept and its key vocabulary.

Key idea

Define and call a procedure in OCR ERL and Python.

A procedure groups instructions for one clear task. ERL starts it with procedure and ends it with endprocedure. Python uses def for both procedures and functions. Defining a procedure stores its instructions, but those instructions do not run until the procedure is called. Calls let the same code be reused without copying it.

Sub-program

A named, reusable block of code that performs a specific task.

Subroutine

Another name for a sub-program, such as a procedure or function.

Procedure

A sub-program that performs a task without returning a value.

Call

An instruction that runs a named sub-program.

Keep these in mind

  • A procedure performs a task but does not return a value.
  • ERL uses procedure ... endprocedure; Python uses def, a colon and indentation.
  • The procedure name should describe its task.
  • A definition must be followed by a call before its body executes.
  • One procedure can be called many times.

Learning objective

Define and call a procedure in OCR ERL and Python.

Exam tip

If OCR asks you to use a procedure, include both its complete definition and an appropriate call in the main program.

Common mistake

Defining a procedure is not the same as running it. A procedure with no call produces no output.

PreviousNext