Coding Education

4 min read

What Is a Constant in Programming?

Published: 10.07.2026·Updated: 10.07.2026
Bayu Nugraha

Bayu Nugraha

Children's Coding Specialist

What Is a Constant in Programming?

A constant is a fixed value in a program that cannot be changed while the program runs. Unlike a variable, whose contents can change again and again, a constant is locked from the start: once it is given a value, that number or text stays the same until the program finishes. Programmers use constants to store values that genuinely should never change, such as pi (π = 3.14), the number of days in a week (7), or the speed of light.

Constants vs Variables

The easiest way to understand a constant is to compare it with a variable. A variable is like a box whose contents you can swap at any time; a constant is like a box that has been glued shut — its contents stay put. In Python, for example, you can write PI = 3.14 and use it to calculate the area of a circle, and the value of PI must not change because pi is always 3.14. Another example: SPEED_OF_LIGHT = 299792 km/s — this number is constant throughout the universe. In Scratch, a child can make a block called “gravity” that always equals 10 and is never changed during the game. In many programming languages, constants are written in ALL CAPITALS so they stand out from ordinary variables. Fun fact: if a program tries to change a constant, the computer shows an error right away — which actually helps programmers avoid mistakes.

Why It Matters for Kids

Learning to tell a constant from a variable trains children to think logically: which data stays fixed and which changes. This idea is the foundation of almost every piece of code they will write. In Algonova's coding courses, kids learn concepts like this through real projects — building games and animations, not memorizing theory.

Want your child to try? Take one free coding class to see how they learn.