Header_blog

Coding Education

4 min read

What Is a Function in Programming: Meaning & Examples

Published: 10.07.2026·Updated: 22.07.2026
Bayu Nugraha

Bayu Nugraha

Children's Coding Specialist

What Is a Function in Programming: Meaning & Examples

A function in programming is a named block of code written once and then called many times to perform a specific task. Unlike a function in mathematics, which turns one number into another, a programming function holds a set of reusable instructions so you never have to write the same code twice.

Table of Contents

How a Function Works

A function is created with a name. Each time that name is called, the program "jumps" to the function, runs everything inside it, then returns to continue with the next line. Functions can also take inputs (called parameters) and return a result.

Imagine a child building a "jump" block in Scratch that makes their character leap. Once the block is made, it can be reused anywhere without rebuilding it. In Python, the same idea is written as def jump(): and then called simply with jump(). One function can be called hundreds of times — so a program that once had 100 repeated lines can shrink to just a few clean, easy-to-fix lines.

Functions with Parameters and Return

A function becomes far more useful when it can take input and give back a result. The input is called a parameter, and the value it hands back is called the return value. For example, in Python a function area(length, width) takes two parameters and returns length * width. With this single function, a child can work out any area just by changing the numbers, without writing the formula again and again. A function that only runs commands without returning a value is sometimes called a procedure. A child can write their first function like this in a free Algonova coding class.

Why It Matters for Kids

Functions teach children to break a big problem into small, orderly pieces — a way of thinking that's useful far beyond coding. By understanding functions, kids learn to write clean, readable code from the start and avoid confusing repetition. This concept is one of the foundations in the Algonova coding course, where children practice building programs from simple blocks and functions step by step.

Want your child to try it hands-on? Sign up for a free class and watch their first function come to life.