A function is a named set of instructions you can use again and again. Instead of writing the steps for “draw a square” four times, you write them once, name them, and call the name whenever you need them.
What your child will learn
- Know what a function is and why it is useful
- Predict what happens when a function is called several times
- Use functions with inputs (parameters), like size or name
- Work out what a simple function gives back
Write once, use many times
In Scratch, “Make a Block” creates a function. Fix a bug inside it and it’s fixed everywhere the block is used. Functions can take inputs: drawSquare(5) and drawSquare(10) use the same steps to draw different sizes.
Example questions
Here are a few questions like the ones in the first quest. Can you solve them?
1. Which is the best name for a function that makes a character wave?
👋- wave
- banana
- x
- thing2
Show answer
Answer: wave. Good names say what the function does.
2. Your “brush teeth” routine has the same steps every time. In coding, we could make it a…
🪥- function
- sound
- bug
- score
Show answer
Answer: function. Repeated routines make great functions.
3. True or false? A function can be used (called) many times in a program.
Show answer
Answer: True. That’s what makes functions so useful.
Tips for grown-ups
- Invent a family “function”, like “bedtime routine”, and list its steps.
- Play a function machine game: “double” — you say 4, they say 8.