Computing · Year 6

Designing and Debugging Complex Programs

💻 ComputingHard18 min

Story time 📖

Tap play and I''ll read this lesson to you like a story.

0
0 of 6

🎮 you are a where a , and its . To make that , your needs to do things in , make and all while the . That mix of is what use every day. In this you will that , and , how and a , and a who called . Let's !

Every is from . run one after another in , like in a . the a and a in this is an IF . a of again and againin this is a . all . For : 10 , IF there is a gem THEN add 1 to , do END . how the a it. like this you with , .

🧠 : The from the of a called . His on the of .

StructureWhat it doesExample in pseudocode
SequenceSteps run in order, one after anothermove forward, pick up gem, move forward
SelectionProgram chooses a path based on a conditionIF score > 10 THEN display 'Winner!'
RepetitionA block of steps is repeatedREPEAT 5 times: move forward END REPEAT
The three building blocks of algorithms

A is like a box the . You it a , a in it, and that as the . For , a called at 0. Each the a gem, the : = + 1. The is out (old one), then the is in the box. let thingsthe , a , how many . , a could not that over .

💡 Tip: , like or than just x or a. make your much to , and .

🔗 Match each programming term to its correct meaning. Drag each term to its definition.

  • Variable

  • Selection

  • Repetition

  • Sequence

  • Nested structure

Now let us an . to be the you each and what to every . at this for the : = 0 = 3 5 : IF gem THEN = + 2 IF THEN = - 1 END After 5 , if the 3 and 1 , would be 6 and would be 2. like thison or in your is one of the most to an before you even run it.

MoveWhat the robot findsscorelives
Start03
1Gem 💎23
2Nothing23
3Gem 💎43
4Trap ⚠️42
5Gem 💎62
Tracing the gem-collecting robot: 3 gems and 1 trap in 5 moves

🧩 🤖 Put these steps of a gem-collecting algorithm into the correct order. Drag them into the right sequence.

  1. End the loop and display final score
  2. IF trap found THEN subtract 1 from lives
  3. IF gem found THEN add 2 to score
  4. Move the robot forward one step
  5. Start the REPEAT loop for 5 turns
  6. Set score = 0 and lives = 3

A is a bug where the but the because the is . It is from a , which is a in or that the at all. are to . the gem : = - 2 of + 2. The would run but the would go of up! To , use these : 1) the . 2) the by . 3) what you with what . 4) the the . 5) Fix and to the fix .

The five systematic steps for debugging a logical error.

⚠️ out: will is not it is ! so you WHY an is before you .

🗂️ 🐛 Sort each item into the correct category — is it a logical error or a syntax error?

  • score = score - 1 when gems should increase score

  • Missing END REPEAT so the loop never closes

  • IF lives = 0 used instead of IF lives < 1 so game never ends

  • A variable spelled 'Scroe' in one line and 'Score' in another

  • Loop repeats 4 times instead of 5 so one gem is never collected

  • IF statement missing its THEN keyword

your , the is . Ask : does the its ? Does it every , ? For , what if 0does the ? Could the be more , using to get the ? their and . You add: IF = 0 THEN ' Over' and the . is not a that your it is a that you like a who to make things . 🌟

🃏 Test your knowledge! Flip each card to check the definition.

Tap each card to see the answer.

Quiz time! 📝

Designing and Debugging Complex Programs — Check Your Understanding

Question 1 of 5

Tip: log in to save your score and track progress.

A is to add 5 to a each they a , but the . What of is this?

Finished?

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