GCSE · Computer Science · AQA · Spec 8525

Boolean data type

Is the password right? Is the level done? To a computer these are not questions. Each one is a value, True or False, and it decides what happens next.

Computer Science · Algorithms

Trace table — dry run the code

A game gives 6 points a round and unlocks a badge once the score is over 10. Before each step, predict what goes in the two comparison columns: True or False?

1score ← 0
2unlocked ← False
3WHILE unlocked = False
4 score ← score + 6
5 IF score > 10 THEN
6 unlocked ← True
7 ELSE
8 OUTPUT "Keep going"
9 ENDIF
10ENDWHILE
11OUTPUT "Badge unlocked!"
score
score > 10
unlocked
unlocked = False
Output
Press Start to run the first line.
·

Ready when you are — step through one line at a time.

What if the flag never flips?

Same badge program. This time, imagine line 6 (unlocked ← True) has been deleted.

What happens when the program runs now?

What does a comparison actually give you?

A program runs this line: result ← 7 > 3

Which of these is closest to what you think right now?
How sure are you?

Which data type should hold it?

Pick an item, then pick the data type that should store it.

Still to sort

Boolean (0)

Only ever True or False.

Where the line is: Exactly two possible states. If a third answer is possible, it is not a Boolean.

Integer (0)

Whole numbers.

Floating point (real) (0)

Numbers that can have a decimal part.

String (0)

Text: a sequence of characters.

Where the line is: Anything stored inside quotation marks is text, even if it spells "True".

7 of 7 still to sort.

A Boolean is one of several common data types. Sort each piece of data into the type that fits it best.

One pair of quotation marks

This program should warn a shopper when an item has sold out. The stock is 0, but no warning appears. Which line is wrong?

A student's program — which line goes wrong?

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

True or False: the one value that decides what a program does next.

What you need to know

  • A Boolean is a data type that can hold only two values: True or False.
  • A comparison such as x > 3 or score > 10 evaluates to a Boolean value.
  • IF statements and condition-controlled loops (like WHILE) use a Boolean value to decide what runs next.
  • A Boolean flag starts as False and is set to True when something happens, such as an item being found.
  • Store two-state data as a Boolean. "True" in quotation marks is a string, not a Boolean.

The big picture

A Boolean is a data type with only two possible values: True and False. Any comparison, such as score > 10 or 7 > 3, is worked out to one of those two values. IF statements use that value to choose which instructions run, and condition-controlled loops such as WHILE check it before every lap to decide whether to repeat. A Boolean flag is a variable that starts False and is switched to True when something happens. Two-state data should be stored as a Boolean, not as text like "True".

Key points

1Boolean is one of the common data types, alongside integer, floating point (real) and string.
2Use a Boolean for data with exactly two possible states, such as on/off or complete/not complete.
3Every comparison is worked out to True or False: 7 > 3 is True, and 3 > 3 is False.
4An IF runs its THEN part when its condition is True, and its ELSE part (if there is one) when it is False.
5A WHILE loop checks its condition before every lap, and repeats only while the condition is True.
6A flag controls a loop only if something inside the loop can change it; otherwise the loop never stops.
7True is a Boolean value; "True" is a string of four characters, and the two do not behave the same.

Worked example

Problem

Dry-run this code and state what it outputs. battery ← 15 lowPower ← battery < 20 IF lowPower = True THEN OUTPUT "Charge me" ENDIF

⚠ Watch out

Putting a Boolean in quotation marks, for example found ← "True". That stores a string that spells a word, not the Boolean value True, so later conditions that test the flag do not behave as intended. Write found ← True, with no quotes.

🧠

Memory hook

Two values, no third, no quotes: a Boolean is True or False, and "True" in quotation marks is just a word.

✓

Check yourself

Without looking back: what does lives = 0 evaluate to when lives is 2, and when lives is 0? For each one, what would IF lives = 0 THEN do with that value?

Flashcards

(10)
What is the Boolean data type?
A data type that can hold only two values: True or False.
Name four common data types.
Integer, floating point (real), Boolean and string.
How do you know data should be stored as a Boolean?
It has exactly two possible states, such as on/off or right/wrong.
Why is the colour of a traffic light not a Boolean?
It has three possible states (red, amber, green), and a Boolean has only two.
What does a comparison such as x > 3 evaluate to?
A Boolean value: True or False.
What does 5 > 5 evaluate to?
False. 5 is equal to 5, not greater than it.
How does an IF statement use a Boolean?
If the condition is True it runs the THEN part; if it is False it skips it (running the ELSE part if there is one).
When does a WHILE loop check its condition?
Before every lap. It repeats while the condition is True and stops when it is False.
What is a Boolean flag?
A Boolean variable that records whether something has happened yet, e.g. found set to False before a search and to True when the item is found.
What is the difference between True and "True"?
True is a Boolean value. "True" is a string: four characters of text that spell a word.

Tap any card to flip it, or use Study as deck to go through them one at a time. In the full lesson these run as a spaced-repetition deck — you rate each card Hard, Good or Easy and the tricky ones keep coming back until they stick.

Learning with Lightbulb is opening soon

You can use this lesson now. Join the waitlist and we'll let you know when the full Lightbulb experience is ready.

Keep me posted

More AQA GCSE Computer Science topics

See the full AQA Computer Science curriculum →

How this lesson was checked. This AQA GCSE Computer Science (specification 8525)lesson was published through Lightbulb Learning's human-designed editorial process — the educational standards, accuracy rules and publication checks it must pass were authored and approved by Philip Halpin. It passed subject-specific assessment, automated educational checks and technical publication verification before going live (publication checks completed 29 September 2026). Published pages are monitored, human spot-checking is ongoing across the lesson library, and anything found wrong is corrected or withdrawn. How our lessons are made and checked. Spotted a mistake? Email hello@lightbulblearning.co and we'll review it.