The dragon explains
Parameters customise the ability
The dragon: def roar(): always does the exact same thing. Parameters let a call CHANGE what happens.
The dragon: def greet(name): — name is a PARAMETER, a blank the caller fills in when they call it.
example.pyPython 3def greet(name): print("Hello,", name)greet("Ember")
OutputHello, EmberThe dragon: Call it again with a different value, and you get a different result — same function, no rewriting.
example.pyPython 3greet("Blaze")OutputHello, BlazeThe dragon: This is the whole idea of 'fireball, but bigger' — one ability, customised each time you cast it.
Quick check
Check your understanding
Say your answer out loud before reading the marked one. Every wrong option is a mistake real beginners make.
Question 1 of 1
def fireball(size): print("SIZE:", size). What does fireball(20) print, compared to fireball(5)?
question.pyPython 3def fireball(size): print("SIZE:", size)
- SIZE: 20 — using the value passed in THIS callCorrect
- 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.
In the game
What you'll practice
Three levels in the game: one guided first try with the shape of the answer already there, then two to solve on your own.
- 1
GuidedYour first try
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.
- +2
PracticeTwo more, on your own
This lesson is part of PRO.
PRO is a one-time $49.99 purchase, no subscription, and unlocks this whole topic along with everything else. Topics 1–3 are free, start to finish.
Unlock this lesson with PROStuck three times? The game offers the answer — unasked.