Skip to content
Menu

Year 9 (ages 13–14, Grade 8 in the US) · Computing · Python: lists and functions · Lesson 2

Functions

Defining and calling Python functions, parameters, return values, the difference between print and return, and why functions help.

Exam boards: this lesson matches the AQA and Pearson Edexcel GCSE computing courses. Check which course your school follows.

Whiteboard video lesson: Functions

14-minute video lesson

Teaching, worked examples and 20 practice questions solved step by step.

Watch free for a month

What your child will learn

  • Define a function
  • Use parameters
  • Return values
  • Call functions

The method

  1. def name(parameters):.
  2. Indent the body.
  3. return a value if needed.
  4. Call it: name(values).

Key words: function, def, parameter, return, call, indent.

Worked examples

Worked examples from the lesson, with every step.

Question 1

What does this code print? (The code is shown below.)

  1. Step 1: Read the code

Answer: HELLO

Question 2

What does this code print? (The code is shown below.)

  1. Step 1: Read the code

Answer: 12

Question 3

What does this code print? (The code is shown below.)

  1. Step 1: Read the code

Answer: 14