Parameters

STEP 2 โ€” Parameters (a.k.a. Giving Your Functions Superpowers)

On to STEP 2. This is where functions stop being cute little tricks and start becoming
customizable, flexible, game-powered machines.

Letโ€™s unleash the chaos.

Alright coder โ€” in Step 1, your functions were like:

โ€œTell me what to do, boss, and Iโ€™ll do it exactly the same way every time.โ€

But now?

Now your functions get parameters, which means they can take input and behave differently depending on what you give them.

Itโ€™s like upgrading your function from a basic toaster to a toaster with settings:

  • light
  • medium
  • โ€œburn it like my hopes and dreamsโ€

Parameters = customization.


1. Whatโ€™s a Parameter?

A parameter is a variable inside a function that waits for information.


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

Now the function can greet ANYONE.


greet("Ava")
greet("Mark")
greet("Sir Fluffington the Third")
Click Run

Your function is now socially adaptable.


2. Why Parameters Matter for Games

Parameters let you build:

  • attack systems
  • healing systems
  • damage calculators
  • item pickups
  • dialogue lines
  • movement commands

Basically, every cool game mechanic ever.

Without parameters, your game is stuck saying the same thing over and over like a broken NPC.


3. Example: Attack Function With Damage


def attack(damage):
    print("You strike the enemy for " + str(damage) + " damage!")

Call it like this:


attack(5)
attack(12)
attack(999)
Click Run

Your hero now hits like a customizable wrecking ball.


4. Multiple Parameters = Maximum Chaos


def heal(player, amount):
    print(player + " heals for " + str(amount) + " HP!")

Call it:


heal("Ava", 10)
heal("Liam", 25)
Click Run

Your game now handles healing like a fantasy hospital.


Practice (Your Turn!)

Mini-Challenge

Create a function called pickup(item) that prints:

You picked up a <item>!

Modify and Run

Your game now reacts to items like a happy loot goblin.

You now understand:

  • what parameters are
  • how to pass information into functions
  • how to customize behavior
  • how to build dynamic game systems
  • how to make your functions 10x more powerful

Your code officially has input-powered superpowers.

Ready for Step 3, where we unlock return values โ€” the feature that lets functions send information back like magical messengers?