Sequence, selection and iteration
Every program ever written is built from three structures. Recognise them and unfamiliar code stops being frightening.
Part of your national curriculum
- Algorithms and programming: Design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems
- Algorithms and programming: Understand several key algorithms that reflect computational thinking, and use logical reasoning to compare the utility of alternative algorithms for the same problem
- Algorithms and programming: Understand simple algorithms, expressed using sequence, selection and iteration, and correct errors in algorithms
Lesson overview
What you'll learn in this lesson
Design algorithms using sequence, selection and iteration
Key learning points
- • The three structures
- • Planning first
This lesson at a glance
- 25 minutes
- 10 parts to scroll through
- 3 quick checks
- Marked quiz at the end
- Gentle pace: short sittings with pauses
Words to know
Scroll down — the lesson carries on below
Watch & discover
Part 1 of 10
Watch first
Sequence, selection and iteration
An English teaching video on this topic from LearnFree. Watch it, then scroll down for the lesson.
In a nutshell
Design algorithms using sequence, selection and iteration
Explore the idea
Part 2 of 10
Learn
The three structures
Sequence runs steps in order. Selection chooses with if/else. Iteration repeats with for or while loops.
Explore the idea
Part 3 of 10
Learn
Planning first
Write the steps in plain English or pseudocode before typing. Decomposition — breaking one big problem into small ones — is the actual skill.
Quick check
Part 4 of 10
Quick check
An if/else statement is…
Quick check
Part 5 of 10
Quick check
A while loop is an example of…
Quick check
Part 6 of 10
Quick check
Decomposition means…
Challenge round
Part 7 of 10
Game · Sort it
Which of these are true?
Drag each card into the right column. Tap a card first if dragging is fiddly.
True
Not true
Challenge round
Part 8 of 10
Game · Fill the gaps
Finish the sentences
Choose the word that belongs in each gap.
____ runs steps in order.
____ chooses with if/else.
____ repeats with for or while loops.
Mastery quiz
Part 9 of 10
Marked quiz
End of lesson quiz: Sequence, selection and iteration
4 questions, marked with the reasoning shown. No timer.
1. An algorithm repeats 'move forward' until a wall is reached, then turns right. Which programming ideas does it use?
2. An if/else statement is…
3. A while loop is an example of…
4. Decomposition means…
Lesson round-up
Part 10 of 10
Lesson round-up
Ready when you are
Quiz score
Not sat
Games
Not played
Points this lesson
0
Best run
0 in a row
Luna: 0 out of 3 on the practice checks. Only if you feel up to it — one more?
Ask LunaDo the work
Your written work for this lesson
This is the part you'd do in your book at school. Pick the pieces below, write here or on paper, and photograph anything you draw or work out.
How a supermarket checkout knows the price
When a barcode is scanned, the checkout does not store the price itself. It sends the barcode number to a database and reads back a record: product name, price, whether it needs an age check. The record is the single place the price lives, so changing one row changes every till in the shop at once.
Problems come from bad data, not bad scanners. If two products share a barcode, or a price update reaches the shop overnight but the till holds an old copy in its cache, customers are charged the wrong amount. Shops check this with test transactions: scan a known item, expect a known price, record what actually happened.
Good systems also log every scan. If a customer complains, the log shows exactly which record was used and when.
Written for Good Learning Co.
Reading questions
- Write in your own words what the checkout sends and what it receives back.
- Explain one way bad data could cause a wrong price, and how logging helps find it.
- Design a test table with four tests for a new checkout, with expected and actual results.
Reading and notes
ReadingRead the lesson text again and note the key terms and how each one is used, in your own words — as you would for revision.
Half a page of notes
Extended writing
WritingExplain a real system that uses this idea — how it works, where it can go wrong, and how you would make it safer or better.
250–350 words
Algorithm on paper
DiagramWrite your steps out as pseudocode or a flowchart before you type anything, then photograph it.
1 flowchart or 10 lines
Code write-up
WritingCopy your code in, then explain underneath what each part does and what you had to fix.
Code + 5 sentences
Test table
Working outMake a test table: what you tried, what you expected, what actually happened.
4–6 tests
Saved as you type.
Part 1 of 10 · Watch & discover
How this is going
- Not looked at yet
Design, use and evaluate computational abstractions that model the state and behaviour of real-world problems and physical systems
- Not looked at yet
Understand several key algorithms that reflect computational thinking, and use logical reasoning to compare the utility of alternative algorithms for the same problem
- Not looked at yet
Understand simple algorithms, expressed using sequence, selection and iteration, and correct errors in algorithms
