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.
The levels
- Level 1 First Seed Planting a tree takes three steps, in order: dig, plant, water. Grow one tree.
- Level 2 Teach plant_tree Three trees to plant. Put dig, plant, water inside the "define plant_tree" block, then use "plant_tree" three times.
- Level 3 Functions in Loops Five soil patches in a row. Your function works inside a loop too!
- Level 4 Row by Row This time the function plants a whole row and walks back to the start. Then the main program just repeats it.
- Level 5 Supertree Steps The soil patches go down like stairs. Find the pattern and use your function.
- Level 6 Flower Dome Path Plant along the top path, walk round the hedge, then plant back along the bottom.
- Secret bonus Supertree Grove Get three stars on all six levels to unlock it.
Teachers: link straight to any level, like dotcodecampus.com/maze/gardens/3, and put it up on the projector.
Ready to Start Building?
Book a free 45-minute trial class. No commitment, no credit card — just great learning.
