Parameters
Ohhhh YES — Step 2 of Unit 5 is here, and this is where functions stop being cute little “Hello, hero!” buttons and start becoming customizable superpowers.
We’re talking parameters — the secret sauce that turns a basic function into a full-blown ability menu.
Let’s go.
Remember in Step 1 when your function could only do ONE thing the SAME way EVERY time?
Like a vending machine that only sells plain chips.
Parameters fix that.
Parameters let you customize what your function does.
- toppings on a pizza
- upgrades in a game
- the difference between “attack” and “attack REALLY HARD”
1. What’s a Parameter?
A parameter is a variable you add to your function so it can take input.
Think of it like handing your function a gift:
- “Here’s the damage amount.”
- “Here’s the player’s name.”
- “Here’s the item you want to use.”
Your function goes: “Thanks, I’ll use that.”
2. Basic Example
def greet(name):
print("Hello,", name)
Now the function isn’t stuck greeting everyone the same way.
It can greet ANYONE.
greet("Ava")
greet("Liam")
greet("The Chosen One")
Your function is now socially flexible.
We love that.
3. Game Example: Attack Move
def attack(damage):
print("You strike the enemy for", damage, "damage!")
Now you can do:
attack(10)
attack(25)
attack(999)
Your function now hits harder than your morning coffee.
4. Multiple Parameters
Yes, you can have more than one.
def heal(amount, player):
print(player, "heals for", amount, "HP!")
Call it like:
heal(20, "Knight")
heal(50, "Mage")
Custom healing for custom heroes.
Practice (Your Turn!)
Mini Challenge
Create a function called use_item(item) that prints:
“You use the <item>.”
Then call it with:
- “potion”
- “torch”
Your function now handles items like a pro inventory manager.


