Functions for kids: Gardens by the Bay

Teach the robot to plant a tree once, then reuse it across the garden.

  • Free
  • No sign-up
  • Ages 6–12
  • Works on Chromebooks and iPads

What are functions?

A function is a set of instructions with a name. You teach the computer a new word once, like plant_tree, and from then on you can use that word anywhere. Functions stop you repeating yourself, and they make programs read like a story: "plant_tree, walk, plant_tree" is much easier to follow than a long list of steps.

In Gardens by the Bay, planting a tree always takes the same three steps: dig, plant the seed, then water it. Put those steps inside the "define" block once, then use the function block wherever a tree is needed. If you later find a mistake, you fix it in one place and every tree gets the fix.

Functions are how real software is built. Apps are made of thousands of small named pieces that call each other. The later levels combine functions with loops, the same way professional code does, and the "Show me the Python" button shows you the def keyword that Python uses to define a function.

Using the Robot Maze in class?

Make a class: students join with a code and a nickname, and you see everyone's stars, and who is stuck, as they play. 14 days free, then S$2.99 a month or S$29 a year. Every world also has a free 45-minute lesson plan with answer keys.