Computing · Year 5

Combining Code: Sequences, Selection and Repetition

💻 ComputingHard18 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 .

StructureWhat it doesBlock-code example
SequenceRuns steps one by one in ordermove forward → turn right → move forward
SelectionTests a condition and branchesif touching wall → turn around else → move forward
RepetitionRepeats a block of coderepeat 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 2the 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.

  1. Display 'You win!' and STOP
  2. End of repeat loop — go back to step 2
  3. IF touching a wall THEN turn 90 degrees
  4. ELSE continue moving forward
  5. IF touching a star THEN add 1 to score
  6. Move the sprite one step forward
  7. REPEAT until all stars are collected
  8. 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.

Which an if/ to between two ?

Finished?

Log in to mark this lesson complete and track your progress.