CurriculumPython Functions, Parameters and return for KidsParameters customise the ability

Python Function Parameters: Customising What a Function Does

Fireball, but bigger — the same function, a different result each time you call it.

Lesson 2 of 5PROAges 10+
See what PRO unlocks →

Parameters customise the ability

def roar(): always does the exact same thing. Parameters let a call CHANGE what happens.

def greet(name): — name is a PARAMETER, a blank the caller fills in when they call it.

def greet(name):
    print("Hello,", name)

greet("Ember")

Output

Hello, Ember

Call it again with a different value, and you get a different result — same function, no rewriting.

greet("Blaze")

Output

Hello, Blaze

This is the whole idea of 'fireball, but bigger' — one ability, customised each time you cast it.

Check your understanding

def fireball(size): print("SIZE:", size). What does fireball(20) print, compared to fireball(5)?

def fireball(size):
    print("SIZE:", size)
  • SIZE: 20 — using the value passed in THIS call
  • SIZE: 5 — the first value it was ever called with

Why: SIZE: 20. Each call passes its own value for the parameter — fireball(20) uses 20, completely independent of any earlier call.

What you'll practice

def greet(name): print("Hello,", name) — the ability now TAKES a name and uses it. Call greet("Ember") and greet("Blaze") — two different dragons, two different greetings.

Unlock this lesson with PRO →

More from this topic

Parameters customise the ability is one lesson inside Python Functions, Parameters and return for Kids — see the full lesson order and what the whole topic covers.

View the full topic →