Python for Kids · Class 7 · Module 4 of 9

Functions and Scope

Every function is a promise: give me this, and I will give you that.

8 sessionsSessions 25–32
4 weeksTypical pace
Foundation to IntermediateLevel
Class 7Python & Coding
A machine with an input arrow, gears inside and an output arrow
The big idea

Students move from writing functions to designing them — deciding what goes in, what comes out, and what the function has no business knowing about. Scope explains why a variable that exists inside a function is invisible outside it.

Why it matters

Function design is the beginning of software architecture. It is also the fastest way to make a long program understandable.

Unpacked

What you will actually learn

Three core ideas, each taught with worked examples and then practised until it feels obvious.

01

Parameters

Parameters define the contract. Fewer, clearer parameters mean a function that is easier to reuse and much harder to misuse.

02

Return patterns

Return patterns matter: return one clear value, return early when the answer is already known, and avoid printing inside a function that is meant to calculate.

03

Local scope

Local scope means variables born inside a function die with it. This is a feature — it stops distant parts of a program from stepping on each other.

Did you know?

The idea of local scope was invented to solve a real crisis: in early languages every variable was global, and large programs became almost impossible to fix.

Common mix-up

“Global variables are simpler.” They are simpler for ten lines and a nightmare at two hundred, because anything can change them from anywhere.

Session by session

Your 8-session journey

Sessions 2532 of the 72-session year, at two one-hour sessions per week.

  1. 1

    Warm-up and big picture

    Where this module fits, what you will build, and a hands-on starter that gets everyone curious about parameters.

  2. 2

    Parameters

    Guided teaching on parameters, worked through together with the teacher.

  3. 3

    Parameters — practice lab

    Independent practice, small challenges and one deliberate mistake to diagnose.

  4. 4

    Return patterns

    Guided teaching on return patterns, building directly on the previous two sessions.

  5. 5

    Return patterns — practice lab

    Applied tasks that combine parameters and return patterns in one piece of work.

  6. 6

    Local scope

    Local scope introduced and practised, completing the toolkit needed for the project.

  7. 7

    Project build

    Guided build session for the module project: Reusable maths challenge engine.

  8. 8

    Test, present and reflect

    Finish, test against the checklist, present the work and explain the decisions behind it.

Project lab

Reusable maths challenge engine

Every module ends with something the student built themselves and can demonstrate. This is the piece that goes into their portfolio and gets explained out loud at the end of session 32.

Try this at home

Build a challenge engine that generates a random maths question, checks the answer and tracks a score — with each job in its own function.

It is finished when

  • It works from start to finish without breaking
  • You can explain every part of it in your own words
  • You tested it and improved at least one thing afterwards
  • Someone else used or understood it without your help

By the end of this module

Students finishing Module 4 can:

  • Explain and use parameters without prompting
  • Explain and use return patterns without prompting
  • Explain and use local scope without prompting
  • Build and finish reusable maths challenge engine
  • Test your own work and correct what you find
  • Talk an adult through what you made and why

Word bank

The vocabulary introduced here, in plain language:

scope
The region of a program where a name is visible.
argument
The actual value passed into a parameter.
side effect
A change a function makes beyond returning a value.
Module challenge

Think you have got this?

0 XPLevel 1 · Curious Beginner

6 quick questions drawn from this module — vocabulary, the project you build, and a myth-or-fact round. Every wrong answer explains itself, so a mistake still teaches you something.

🎯 6 questions⚡ Up to 80 XP

Your child's free trial is one message away.

Tell us your child’s class and what they enjoy. We will suggest the closest program fit—no pressure and no upfront payment.