Full lesson Functions 3–7 min

Functions: Teach Bit a Trick!

Can Bit reuse a cheer without copying every step?

Real Python code

This is the code from the video. Read it out loud like a recipe, one line at a time!

cheer.py
def cheer():
    print("Ready!")
    print("Go!")

cheer()
cheer()

Quiz time!

How many times does Ready! print?

quiz.py
def cheer():
    print("Ready!")
    print("Go!")

cheer()
cheer()

Functions in real programs

Games

Call a function to reset a round.

Messages

Call a function to format a greeting.

Loops and functions

A loop repeats. A function names steps.

Define it. Call it. Reuse it.

Only define

  • Name the trick
  • Write its steps
  • Steps are ready
VS

Then call

  • Use the name
  • Run the steps
  • Continue afterward

A function is a named, reusable group of steps.

Try it yourself!

On paper, name a two-step cheer and write two calls. Change one step in the definition, then follow both calls again.

Bit is working on the next one: Lists: keep several things together

Liked this quest?

Subscribe to see the next one first! Ask a grown-up before subscribing.

Keep exploring