AI or coding first: which should your child learn?

Coding Education

Hafiz Rahman
Lead Coding Instructor at Algonova Malaysia

Table of Contents
In programming, a function is a named, reusable block of code that performs one specific task and runs only when you "call" it. Unlike a function in mathematics — where an input like x always maps to a single output — a programming function is a set of instructions you write once and reuse anywhere. It may return a value, change something on the screen, or take no input and produce no visible result at all.
A function has three parts: a name, an optional set of inputs (called parameters), and a block of instructions to run. You define it once, then "call" it by name whenever you need it. In Scratch, a child can build a custom block called "jump" that moves a sprite up and back down; every time they drop in the "jump" block, the same steps run — no need to rebuild them. In Python the same idea looks like def jump(): followed by the instructions, and you run it simply by typing jump().
Programmers rely on functions because they follow the DRY principle — "Don't Repeat Yourself." Writing the jump logic once and calling it ten times keeps code short, easier to read, and simpler to fix: change the function in one place and every call updates automatically. Even a small game can call the same function hundreds of times.
A function is one of the first "big ideas" a child meets in coding, and it builds real thinking skills — breaking a problem into smaller, named steps is the same logic behind KSSR problem-solving and wider STEM learning. Learning to write a function teaches a child to plan before they build. Kids explore this hands-on in Algonova coding classes, and our guide on what coding is for kids gives more context.
Want to see your child write their first function? Book a free trial class and watch them build one live.
Programmers use functions so they can write a block of code once and reuse it many times instead of repeating themselves. A function takes an input, does a job, and often returns a result, which keeps programs shorter, tidier and easier to fix. For example, one 'drawSquare' function can draw a hundred squares. This idea appears in every language, from Scratch blocks to Python. Kids practise writing and calling their own functions in Algonova's coding classes, and a free trial class shows how one function can save a lot of typing.
A function is a named, reusable block of code that does one specific job and runs only when you call it by name. You write the instructions once and reuse them as many times as you like.
A maths function maps an input to exactly one output. A programming function is a set of instructions that may return a value, change the screen, or do something else entirely — and it can take no input at all.
To follow the DRY principle — "Don't Repeat Yourself." Functions let you write logic once and reuse it, which keeps code shorter, easier to read, and simpler to fix in one place.
Children can meet the idea from around age 8–9 using Scratch custom blocks, then write real functions in Python from about age 11–12.
Start your child's tech journey
Book your free 60-minute trial class with an Algonova certified tutor. No payment, no obligation, just discover what your child can build.