CurriculumThe Dragon's Abilities

Python Functions, Parameters and return for Kids

A function lets you name a piece of code once and run it again as many times as you like.

15 exercises5 lessonsAges 10+PRO
See what PRO unlocks →

What this topic covers

Functions start simply: def names a group of code, and nothing happens until that name is actually called — a distinction children need stated directly, since a common misreading treats defining a function as running it. Parameters follow immediately after, framed as customising an ability rather than as abstract 'inputs', since the same function producing a different result each time it's called is the whole point.

The hardest idea in this topic, and the reason it is sequenced this late, is return. Research on introductory programming finds the confusion between return and print persistently resistant to direct teaching, and it is worse here than in most curricula, because print() has been the mechanism by which the game world visibly reacts since the very first topic — so 'make something happen' and 'print' fuse early and hold on tight.

This topic gives return a genuinely separate, visible destination rather than asking children to take the distinction on faith: a function that returns a value hands it to a real second channel, distinct from anything print() can do, so the difference between showing a value and handing one back is something a child can see rather than something they're told.

Python from this topic

def compute_damage():
    return 10

deliver(compute_damage())

Output

10 delivered

Python covered here

  • Defining a function with def
  • Calling a function, and calling it more than once
  • Parameters that customise what a function does
  • return hands a value back — it does not display it
  • A function call finishes and your code continues afterward
  • Choosing whether a function should print or return

The mistake this topic is built to fix

Common mistakeA child believes a returned value is automatically shown, the same way a printed value is, or that calling a function jumps away and never comes back.

Documented as resistant to direct instruction, and made worse by a game whose core mechanism up to this point has been print() as the world's reaction. This topic gives return its own real destination so the difference is visible on screen rather than asserted in prose.

The lessons, in order

  1. def gives your code a nameWrite it once, call it as many times as you like — no retyping.3 exercises
  2. Parameters customise the abilityFireball, but bigger — the same function, a different result each time you call it.3 exercises
  3. return hands a value backreturn doesn't print anything — deliver() is where a returned value actually goes.3 exercises
  4. The Dragon's Two Abilitiesprint() shows it, deliver() sends it — choosing the right channel for each function.3 exercises
  5. Lists leak out. Numbers don't.A function can change your list forever — but a number is safe no matter what happens inside.3 exercises

Lessons unlock in order within a topic, so nothing arrives before the idea it depends on. This topic is part of PRO — $6.99 unlocks it along with everything else.

Try it now

The very first level needs no account at all — see whether it clicks before signing up for anything.

Play the first level free →