Python for Kids · Class 9 · Module 3 of 9

Functions as Interfaces

Write a function once. Document it well. Never think about it again.

8 sessionsSessions 17–24
4 weeksTypical pace
Intermediate to AppliedLevel
Class 9Python & Coding
A documented function card beside three passing tests
The big idea

Functions become interfaces — contracts other code depends on. Students learn flexible arguments, docstrings that explain the contract, and tests that prove it still holds after changes.

Why it matters

Reliable, documented functions are what make a codebase survivable across months. This is the beginning of real software craftsmanship.

Unpacked

What you will actually learn

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

01

Arguments

Arguments can be positional, keyword or defaulted. Sensible defaults make the common case simple and the unusual case still possible.

02

Documentation

Documentation means a docstring stating what the function takes, what it returns and any assumption it relies on. Three lines is usually plenty.

03

Testing functions

Testing functions means writing code that checks the code — normal input, edge input, and input that ought to fail loudly.

Did you know?

Python can read its own docstrings: calling help(your_function) prints them straight back. Documentation is a built-in feature, not an afterthought.

Common mix-up

“Tests are for professionals.” Tests are for anyone who intends to change their code later without dreading it.

Session by session

Your 8-session journey

Sessions 1724 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 arguments.

  2. 2

    Arguments

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

  3. 3

    Arguments — practice lab

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

  4. 4

    Documentation

    Guided teaching on documentation, building directly on the previous two sessions.

  5. 5

    Documentation — practice lab

    Applied tasks that combine arguments and documentation in one piece of work.

  6. 6

    Testing functions

    Testing functions introduced and practised, completing the toolkit needed for the project.

  7. 7

    Project build

    Guided build session for the module project: Reusable school utility library.

  8. 8

    Test, present and reflect

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

Project lab

Reusable school utility library

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 24.

Try this at home

Write a utility library with five functions, each with a docstring and three tests. Then break one on purpose and confirm the tests catch it.

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 3 can:

  • Explain and use arguments without prompting
  • Explain and use documentation without prompting
  • Explain and use testing functions without prompting
  • Build and finish reusable school utility library
  • 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:

docstring
A documentation string inside a function or module.
default argument
A parameter value used when none is supplied.
unit test
A check that one small piece of code works.
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.