Building Blocks of Code: Mastering Functions

1 of 4

ICT

Building Blocks of Code: Mastering Functions

3 more
1/4
For grown-ups

Companion summary

Have you ever wondered how one button tap can unlock your phone, play a sound, and light up the screen all at once? Functions are the secret — programmers bundle instructions once, then call them wherever needed, saving hours of work. Every app you use, from maps to games, runs on thousands of named functions working together like a well-rehearsed team. When you are ready, try writing a function that greets a user by name and see how easily you can reuse it.

The Recipe Shortcut

The Recipe Shortcut

Imagine you are a baker who makes the same sponge cake every single day. Would you write out the full recipe from scratch each time — measure, mix, bake, cool — or would you keep one master recipe card and just follow it whenever you need it? Most experienced bakers keep the card. Now think about code. If you needed to calculate the area of a rectangle in ten different places in your program, would you type out the same calculation ten times? Or would it be smarter to write the calculation once and simply call it whenever you need it? That 'recipe card' idea is exactly what a function is in programming. Before you read on, jot down: what do you think a function might look like in code?

💭 Think about this

If you had to give someone the same set of instructions over and over again, what shortcut would you invent to save time?