Thinking in Code
Math · Foundational · Lesson 9 of 9

Functions

Name it once, use it everywhere

An interactive lesson with 7 steps, about 6 minutes: you predict, drag and solve, with instant feedback on every answer. It runs in your browser and needs JavaScript.

What you’ll learn

  • A function is a named, reusable piece of code; def defines it, calling runs it.
  • Arguments fill the function’s variables; return hands back a value.
  • Functions avoid repetition; recursive functions call themselves on smaller cases.

Steps

  1. Making your own instructions
  2. Watching a call
  3. A function of a function
  4. A flower from squares
  5. Why bother?
  6. A function that calls itself
  7. A recursive sum