Combining Code: Sequences, Selection and Repetition
💻 ComputingHard⏱ 18 min
🪙0
0 of 7
🎮 a who , if there is a , and it a . That is a — and that : ( things in ), ( ) and ( ). every all . you will how they to — and how to when .
✨
🧠 Did you know? The on a of per , but every one into just : , or . The your , and even !
Let's each . A is a set of out one after another, in a — like a . the a and one of two : if the is it does one thing, it does . (also called a ) a of is over and over — a of or a . Each is , but them you that can to and .
Structure
What it does
Block-code example
Sequence
Runs steps one by one in order
move forward → turn right → move forward
Selection
Tests a condition and branches
if touching wall → turn around else → move forward
Repetition
Repeats a block of code
repeat 10 times → move forward
The three core programming structures at a glance
When you all , . a in a . The () all are . the , it (), then it has hit a () — if yes, it ; if no, it . The the thing again and again. The to what is . The makes each in the . any one and the . They are . 💪
💡
📝 before you ! a . and , ( ), (), and . A when you in .
🔗 Match each flowchart shape to what it represents in a program. Drag each shape name to its correct meaning.
Oval
Rectangle
Diamond
Arrow looping back
Now let's about — using what you know about how to 🐛. A bug is an that makes the . There are two . A the are in a way the — like a . A the run , but the is — for , your when it should . To , through the by in your , what each does and the and are .
⚠️
⚠️ out for ! If your can — for , ' = 7' but the only by 2 — the will and . that your has a .
🗂️ A programmer wrote a sprite-maze program but made some mistakes. Sort each problem into the correct bug type.
The 'if touching wall' block has no 'else' branch connected
The sprite turns right when it should turn left at every junction
The repeat block has no blocks inside it
The score goes up by 2 but the win condition checks for score = 5
A block is placed outside the main script and never connected to the Start block
Here is a for a , in so you could it as a or it in . the — this is how a before any . how , and each a at in the .
🧩 Put these algorithm steps in the correct order to make a working star-collecting sprite program. Drag them into the right sequence.
Display 'You win!' and STOP
End of repeat loop — go back to step 2
IF touching a wall THEN turn 90 degrees
ELSE continue moving forward
IF touching a star THEN add 1 to score
Move the sprite one step forward
REPEAT until all stars are collected
START the program
🃏 Test your key vocabulary! Flip each card to check the definition.
Tap each card to see the answer.
✍️ Complete the sentences below using the word bank to check your understanding of all three structures.
A one after another. A an if/ to between two . A a of a is met.
💡
🌟 Top tip for your : by your in , then a , THEN it in . your for and before you will you of !
Quiz time! 📝
Combining Code: Sequences, Selection and Repetition — Check Your Understanding
Question 1 of 5
Tip: log in to save your score and track progress.
Finished?
Log in to mark this lesson complete and track your progress.