Skip to content
Your progress

Checking your sign-in…

Who's learning?

Each profile keeps its own read lessons, badges, streak, and practice scores on this device.

Lesson 9 of 11

The big picture

Show on a big screen

3 min

Text size

Lessons 1 to 4 build a function. Lessons 5 to 8 find what went wrong.

Functions and Debugging, in eight lines
IdeaRememberExample
A name for stepsfunction names lines. Output does not change.Same 8 lines print
What you hand itA parameter starts empty. An argument fills it.stops: dash, then 3
The value it hands backreturn sends a value out. Print sends nothing.ticketFare(3) gives 8
One call inside anotherThe inner call finishes first.total(morning) before max
A print in the middleIt shows a box right then.print(off) shows 6
One line at a timeA dash means the box is not made yet.3 riders give 18
Predict, then runPredict from the job. Check the first difference.Purse 8 differs
Halve the huntCheck the middle. Drop the innocent half.4 checks, not 10

Two questions help in every bug hunt. What does a box hold? Where should I look next?

Name the part that repeats. Hand it a value. Predict before you run.