GCSE · Computer Science · Eduqas · Spec C500QS

Selection in programs

Same code, four different inputs, four different paths. Which lines run, and which get jumped over?

Computer Science · Selection

Follow the input through the code

Same program, four inputs. Call each step before it appears.

Choose an input, step through the program, and call each result before it appears.

score = int(input("Score out of 10: "))
if score == 10:
print("Perfect")
elif score >= 5:
print("Pass")
else:
print("Retry")
print("Next question")

Variables

score=7

Step 1. The program asks for a score. 7 is typed in and stored in score.

Step 1 of 5Called right: 0 of 3

Ask yourself two things at every condition: is it True or False, and which line runs next?

​

Computer Science · Selection

One decision, three ways to write it

  1. 1 Explore
  2. 2 Spot the mismatch
  3. 3 Spot the mismatch

Model. A tiny two-path program drawn three ways. The flowchart is shown as a table of its parts: a real flowchart draws them as shapes joined by arrows.

Step 1 · Explore

Tap the condition in one form and see where it lives in the other two. Then tap each block and follow it across.

Linked parts: select one to follow it through every representation

if :

if, a condition and a colon. Then the indented block underneath. Then else, a colon and another indented block.

Linked parts tried: 0 of 2.

Computer Science · Selection

What does each form guarantee?

For each form, tick every property that is true, then check. Assume the forms with elif have just one elif.

if on its own
if with else
if / elif / else
if / elif, no else

Computer Science · Selection

Two conditions are True. Now what?

temp holds 35, and the program runs: if temp >= 30: print("Hot") elif temp >= 20: print("Warm") else: print("Cool") print("Done")

35 is bigger than 30 and bigger than 20, so both conditions are True. Which idea is closest to what you think happens?
How sure are you?

Computer Science · Selection

Find the line that sends 85 the wrong way

A student wants 70 or more to print Distinction, 40 to 69 to print Pass, and anything lower to print Fail. For a score of 85 their program printed Pass. Which line sends 85 down the wrong path?

A student's program and dry run — which line goes wrong?

Computer Science · Selection

Now you write it

A game gives a medal from a score. Write Python-style code that prints Gold for 90 or more, Silver for 60 to 89, and No medal for anything below 60. After that, the program must always print Game over. The score is already stored in score. [7 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.

How a program picks one path through its code, and skips the rest.

What you need to know

  • Selection is used when a program has more than one possible path to follow.
  • A condition is an expression that works out to True or False.
  • Have a goPriya insists that the condition 10 > 3 is 'kind of True, kind of False'. Is she right?

    No. 10 > 3 is True.

    A condition always works out to exactly one of True or False, so there is no 'kind of'.

  • The program checks the condition, then picks the path: a block of code only runs if its condition is True.
  • In the Python-style code here, you write if, a condition and a colon, then an indented block of code underneath.
  • Add else with its own colon and indented block, and code can run on either of the two paths.
  • Have a goA program says: if weight <= 20: print("OK"), else: print("Pay extra"). The weight is 25. Which line prints?

    Pay extra

    25 <= 20 is False, so the if block is skipped and the else block is the path that runs.

  • The double equals, ==, is a comparison operator that checks whether one value is equal to another.
  • For three or more options, add elif. The program checks the conditions one by one and picks the first True one.
  • You can use several elif blocks, and the else and its block are optional.
  • Have a goA program has an if and an elif but no else, and both conditions are False. Can neither block run?

    Yes. Neither block runs and the program carries on.

    Without an else there is no fallback path, so when every condition is False nothing in the selection runs.

  • The blocks that were not picked are skipped, and execution carries on at the line after the selection.
  • In a flowchart, the decision symbol is a diamond holding the condition, with arrows labelled True and False.

The big picture

Selection lets a program follow more than one possible path. It checks a condition that is True or False, runs the block for the first True path, skips the other blocks and carries on at the line after the selection.

Key points

1Selection gives a program more than one possible path, chosen by a condition that is True or False.
2A block only runs if its condition is True. In multi-path selection, only the first True condition's block runs.
3The unchosen blocks are skipped, and execution continues at the line after the whole selection.
4elif adds more conditions, and the else is optional. A flowchart shows a decision as a diamond with True and False arrows.

Worked example

Problem

A ride program runs: age = int(input("Age: ")) if age < 13: print("Child fare") elif age < 65: print("Adult fare") else: print("Senior fare") print("Enjoy the ride") The age typed in is 40. Which condition is True first, what is printed, which blocks are skipped, and where does the program go next?

⚠ Watch out

Thinking every block whose condition is True will run, or that the else runs as well. In multi-path selection only the first True condition's block runs, and then the program carries on after the whole selection.

🧠

Memory hook

Top to bottom, first True wins, then carry on below.

✓

Check yourself

Cover the page. An if / elif / else gets an input that makes both conditions True. Which block runs, which are skipped, and where next?

Flashcards

(12)
What is selection?
A way for a program to choose between more than one possible path. It checks a condition and follows the path that goes with it.
What is a condition?
An expression that evaluates to True or False.
Which statements carry out selection in Python-style code?
if, elif and else.
What comes after the condition in an if line?
A colon, then an indented block of code underneath.
When does the block under an if run?
Only when its condition is True.
What does == do in a condition?
It is a comparison operator. It checks whether a value is equal to another value.
When do you need an if and an else together?
When code should run on either of two possible paths: if the condition is True one block runs, otherwise the else block runs.
What does elif let a program do?
Choose between three or more options. The program checks the conditions one by one and follows the first one that is True.
What happens to the blocks that are not picked?
They are skipped, and execution continues at the line after the selection.
Which parts of if / elif / else are optional?
The else and its block. You can also use more than one elif.
Which flowchart symbol shows a decision?
A diamond, with the condition inside it.
What are the two arrows leaving a decision diamond labelled?
True and False.

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 16 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.