GCSE · Computer Science · Eduqas · Spec C500QS

Selection

Same program, different input, different route. The code never changes, so what makes the program go one way instead of the other?

Computer Science · Selection

Same program, different route

Pick a run. At each marked step, call what goes in the outcome column before the trace table shows it. All the scores are made up.

INPUT score
IF score >= 90 THEN
OUTPUT "Top score!"
END IF
IF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Retry"
END IF
OUTPUT "Done"
scoreoutcome
95

Step 1. Run 1 starts. The made-up score 95 is stored in score. This first step is already worked out for you.

Step 1 of 6Called right: 0 of 1

Work out the test with this run's score, then check the outcome column.

Computer Science · Conditions

Could this go after IF?

Sort each made-up line: could it be the condition after IF, or not?

Still to sort

A condition (0)

Works out to true or false

Where the line is: Ask yourself: could this ever give an answer other than true or false?

Not a condition (0)

Gives a value or does a job

Where the line is: A number, some text or an instruction is not a test, even if it sits near one.

6 of 6 still to sort.

Exam line: A condition is a Boolean expression, so it evaluates to true or false and nothing else.
Watch out: A line can look like a test and still be a job. If it can give any answer other than true or false, it cannot sit after IF.

​

Computer Science · Flowcharts

One decision, three forms

  1. 1 Explore
  2. 2 Spot the mismatch

Model. A made-up decision shown in three forms. The flowchart is written out as text so it fits on the page: the diamond holds the condition and each exit is labelled.

Step 1 · Explore

Tap the condition, then the true path, then the false path. Watch where each one lights up in the other two forms.

Linked parts: select one to follow it through every representation

IF THEN

ELSE

END IF

Linked parts tried: 0 of 2.

Computer Science · ELSE IF

Three conditions are true. Which block runs?

A made-up chain: IF score >= 90 THEN OUTPUT "Gold", ELSE IF score >= 70 THEN OUTPUT "Silver", ELSE IF score >= 50 THEN OUTPUT "Bronze", ELSE OUTPUT "No medal". The score is 95, which is at least 90, at least 70 and at least 50.

Which is closest to what you think happens when the score is 95?
How sure are you?

Exam line: ELSE IF: test in order, run the block of the first true condition, and do not test the rest. The final ELSE runs only when none is true.

Computer Science · Nested selection

Find the line that cannot have happened

A made-up program has an inner IF inside the THEN branch of an outer IF. Outer: IF age >= 12. Inner (inside the THEN branch): IF height >= 140 THEN OUTPUT "Ride" ELSE OUTPUT "Too short". The outer ELSE outputs "Too young". Below is a student's trace for age 10 and height 150. One line is wrong. Which one?

A student's trace table — which line goes wrong?

Exam line: Before you record an inner test in a trace table, check that the outer test sent the program down the branch it lives in.

WHAT YOU'VE LEARNED

A quick recap of today's lesson.

How a program decides which path to take.

What you need to know

  • Selection means the program tests a condition, and the result decides which instructions run next.
  • A condition is a Boolean expression: it works out to true or false, nothing else.
  • IF ... THEN runs its block only when the condition is true.
  • When the condition is false, the block is skipped and the program carries on after the structure.
  • Have a goSam says: "The condition came out false, so the whole program just stops dead." Is Sam right about what happens next?

    No. The block is skipped and the program carries on after the structure.

    A false IF ... THEN only skips its own block. Everything after the structure still runs.

  • Add ELSE and the THEN block runs for true, the ELSE block for false: exactly one block runs.
  • Have a goA made-up program says IF age >= 12 THEN OUTPUT "Older" ELSE OUTPUT "Younger". Age is 9. Which block runs, THEN or ELSE?

    ELSE, so Younger is output.

    9 >= 12 is false, so the THEN block is skipped. It is not a case of both blocks running.

  • ELSE IF tests conditions in order. The first true one runs its block and the rest are not tested.
  • An optional final ELSE runs only when none of the conditions is true.
  • Have a goA chain tests score >= 90, then score >= 70, then has a final ELSE. The score is 95. How many of the conditions get tested?

    One: score >= 90 is true, so its block runs and the others are not tested.

    ELSE IF stops at the first true condition. It does not keep testing just because later conditions would also be true.

  • Selection can be nested: an inner selection is only tested if execution reaches its branch.
  • In a flowchart, a diamond holds the condition, with one exit for true (Yes) and one for false (No).
  • A trace table records each condition's outcome and each variable's value as you follow the path.

The big picture

Selection lets a program choose. It tests a condition, which is a Boolean expression so it is either true or false, and the result decides which block runs next. IF ... THEN skips its block when the condition is false, IF ... THEN ... ELSE always runs exactly one block, ELSE IF takes the first true condition, and selections can be nested inside each other. A flowchart shows the decision as a diamond with Yes and No exits, and a trace table records each condition's outcome as you follow the path.

Key points

1The condition's outcome picks the path. In an ELSE IF chain, the first true condition in the written order wins.
2A false IF ... THEN skips its block and the program carries on afterwards.
3IF ... THEN ... ELSE always runs exactly one of its two blocks.
4In ELSE IF, only the first true condition's block runs and the rest are not tested.
5An inner selection is only tested if its branch is reached.

Worked example

Problem

A made-up ticket program: INPUT age. IF age < 16 THEN SET price TO 4 ELSE SET price TO 8 END IF. OUTPUT price. What price is printed for someone aged exactly 16?

⚠ Watch out

Thinking a false condition stops the program, or that every block runs. A false IF ... THEN only skips its own block, and in IF ... THEN ... ELSE and ELSE IF only one block runs.

🧠

Memory hook

Test it, then take one road: the condition picks the path, and in an ELSE IF chain the first true test in the written order wins.

✓

Check yourself

A made-up program says IF score >= 50 THEN OUTPUT "Pass" ELSE OUTPUT "Retry", then OUTPUT "Done". The score is 49. Without looking back, say what is printed, in order, and which block was skipped.

Flashcards

(11)
What is selection in a program?
A construct where a condition is tested and the result decides which block of instructions runs next.
What kind of expression is the condition in selection?
A Boolean expression: it evaluates to either true or false.
When does the block in IF ... THEN run?
Only when the condition is true.
What happens after a false IF ... THEN condition?
The block is skipped and the program carries on with the instruction after the structure.
How many blocks run in IF ... THEN ... ELSE?
Exactly one: THEN when the condition is true, ELSE when it is false.
How does an ELSE IF chain choose a block?
The conditions are tested in order. The first true one runs its block and the remaining conditions are not tested.
When does the final ELSE in an ELSE IF chain run?
Only when none of the conditions is true.
When is a nested (inner) selection tested?
Only when execution reaches the branch it sits inside.
What does a decision diamond in a flowchart hold, and how does it exit?
The condition. Its Yes exit is followed when the condition is true and its No exit when it is false.
What does a trace table record for a selection?
The outcome of each condition and the value of each variable.
What decides which block runs when a program reaches a selection?
The outcome of the condition. In an ELSE IF chain, the first true condition in the written order picks the block. The code stays the same but the route changes with the input.

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 Eduqas GCSE Computer Science topics

See the full Eduqas Computer Science curriculum →

How this lesson was checked. This Eduqas GCSE Computer Science (specification C500QS)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 28 November 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.