KS3 · Computer Science

Selection: making decisions in code

The same theme park ticket program charges a 9-year-old 18 and a 14-year-old 25. It asks one question about age, gets True or False, and follows just one path.

Computer Science · Selection

The ticket program’s fork

One visitor, aged 9. Step through and watch which path lights up, and which one never does.

Before you press Next: will a 9-year-old be charged 25 or 18?

TrueFalseStartage = 9age > 12?price = 25price = 18End

Output

 

Step 1: The ticket program starts.

1 / 5

Press Next and follow the lit-up path. Watch the other price box.

Step 1 of 5: The ticket program starts..

Watch out: In one run the program follows the True path or the False path. It never follows both.

Computer Science · Conditions

Make the call: True or False?

Pick a card, then pick the box it belongs in. Commit first, then read why.

Still to sort

Evaluates to True (0)

The comparison holds for those values.

Where the line is: When the two values are equal, >= and <= give True but > and < give False.

Evaluates to False (0)

The comparison does not hold for those values.

Where the line is: False is a proper result, not an error. It is what sends a program down its other path.

8 of 8 still to sort.

A condition is just a question your program can answer with True or False. Each card shows a variable’s value and a condition.

Computer Science · Logical operators

Joining conditions: and, or, not

A login checks two things. A is “the username is admin”. B is “the password is password123”. For each row, decide which of the three results is True, then check your grid.

A True, B True
A True, B False
A False, B True
A False, B False

Computer Science · if and else in Python

Spot the slip in the PIN check

Here is the fork in real Python. The True path goes under if, the False path goes under else, and only one of them runs. In Python, if and else are lowercase, each is followed by a colon, and the code inside each is indented. Remember too: = stores a value, and == compares. This ATM program asks for a PIN, then outputs "Access Granted" if the PIN is 1234 and "Access Denied" if it is wrong. One line is faulty. Which one?

A student’s ATM program — which line goes wrong?

Computer Science · Control structures

Where selection fits

Programs are built from control structures. Describe the three main ones, and name an example of selection. [4 marks]

0 words · your answer stays on this page and is not sent anywhere.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

What you need to know

  • Selection means a program has more than one possible path and picks one by checking a condition that evaluates to True or False.
  • In a flowchart, selection is a decision symbol with a True path and a False path coming off it.
  • In Python, selection uses if and else: the if block runs when the condition is True, the else block runs when it is False, and only one of them runs.
  • = assigns a value to a variable. == compares two values.
  • The logical operators and, or and not join conditions into a single True or False result.
  • The main control structures are sequence, selection and iteration.

The big picture

Selection lets a program choose between paths by checking a condition that evaluates to True or False. In Python you write it with if and else, and only one of the two blocks ever runs.

Key points

1A condition is an expression that evaluates to True or False.
2Relational operators compare two values: ==, !=, <, <=, > and >=.
3if and else give two possible paths, but only one block runs each time.
4Use == to compare. Use = to assign.
5and needs both conditions True; or needs at least one; not reverses.
6An if statement is an example of selection.

Worked example

Problem

A program has a variable called user. Write Python that outputs "Welcome back" if user is equal to the string "Alex", and outputs "Please sign up" if it is not.

⚠ Watch out

Two slips catch people out. One: writing = when you mean ==. = is for assignment, so if pin = 1234: is a syntax error. Two: thinking the if block and the else block both run. Never. The condition is True or False, and that picks exactly one block.

🧠

Memory hook

One equals puts it in. Two equals asks the question.

✓

Check yourself

age is 12. What does age > 12 evaluate to? What does age >= 12 evaluate to? Which of the two would send a program down its if block?

Flashcards

(14)
What is selection?
A program checks a condition that evaluates to True or False and follows one of two possible paths.
What is a condition?
An expression that evaluates to True or False.
In a flowchart, what shows selection?
A decision symbol with a True path and a False path coming off it.
In Python, when does the else block run?
When the condition is False. The if block runs when it is True, and only one of the two runs.
What is the difference between = and == in Python?
= is assignment (it stores a value). == is comparison (it checks whether two values are equal).
Which operator means “not equal to”?
!=
What does >= mean?
Greater than or equal to.
If age is 12, what does age > 12 evaluate to?
False. 12 is not greater than 12.
Which Python rules apply to if and else syntax?
No capitals, a colon after the if and after the else, and the code inside each block indented.
When is A and B True?
Only when both A and B are True.
When is A or B True?
When at least one of A and B is True.
What does not do?
It reverses the answer: True becomes False and False becomes True.
Name the three main control structures.
Sequence, selection and iteration.
What does iteration do?
It runs the same lines of code more than once (looping).

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 KS3 Computer Science topics

See the full KS3 Computer Science curriculum →

How this lesson was checked. This KS3 Computer Sciencelesson 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 9 October 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.