Skip to content
Exit presentation

Computational Thinking III: Functions & Debugging

The big picture

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.

Jump to lesson

This track

  1. 0 Start here
  2. 1 A name for a group of steps
  3. 2 What you hand it, and what each end is called
  4. 3 The value it hands back
  5. 4 One call inside another
  6. 5 A print in the middle
  7. 6 One line at a time
  8. 7 Predict, then run
  9. 8 Halve the hunt
  10. 9 The big picture
  11. 10 Track quiz

Other tracks