Coding Education

5 min read

What Is a Boolean? True/False Values in Programming

Hafiz Rahman

Hafiz Rahman

Lead Coding Instructor at Algonova Malaysia

What Is a Boolean? True/False Values in Programming

A boolean is a data type that can hold only one of two values: true or false. Named after mathematician George Boole, it is how a computer answers a yes/no question — is the light on, is the game over, did the player win? A boolean is always either true or false, never anything in between.

How a Boolean Works

Booleans usually come from a comparison. When code asks if (score > 10), the computer checks the score, produces a boolean — true if the score really is above 10, false if it is not — and then decides what to do next.

In Scratch, the green pointed blocks like key space pressed? or touching edge? are booleans; they slot into an if block and report true or false. In Python, age >= 7 gives back True or False, and you can store it: can_play = age >= 7. A fun fact: because a computer only has two states — on and off — booleans map perfectly onto the 1s and 0s inside every chip.

Why It Matters for Kids

Booleans are the foundation of decisions in code — every if, every loop that stops at the right moment, and every game rule relies on true/false thinking. Learning them builds the logical, computational thinking that Malaysia's KSSR curriculum and STEM education encourage. Children practise booleans from their first projects in Algonova coding classes, and they pair naturally with what a variable is.

Curious to see it in action? Book a free trial class and watch your child code their first true/false rule.