Computing · Year 4

Variables and Keeping Score

💻 ComputingMedium14 min
0
0 of 5

you are a and you need to your . You could the on a , rub it out, and a new each you a . A in a the way. It is a that can a and that can as the . 🎯

The from the for . In you see x or y used as . In , have like , , or so the what is .

of a as a box. The is the and is the box is its . You can the box at any , what is in it, or add to it. A at 0. Every the an , the the box, 1, and the new in. 📦

Variable nameWhat it storesExample value
scoreHow many points the player has earned7
livesHow many chances the player has left3
playerNameThe name typed in by the playerPriya
Three common variables in a simple quiz game

In like , you a by Make a and it a . You then use to set the at the and it during the . The set a in the box. The by or a from is there. These two are your key for a . 🧩

set your to 0 at the very of your . If you , the on from a and the . This is called the it before it is .

🔗 Match each coding block to what it does. Drag the block name to the correct description. 🔗

  • set score to 0

  • change score by 1

  • if answer = correct

  • say score

when you them with the other you know. in . through again and again. using an if to the got the before the . these let you a , . 🎮

and ! After you your , it and for . A bug is a in the . If the up when it should not, which is the by . is called and every does it, even the .

🧩 Put these steps in the correct order to build a simple score-keeping quiz game. Drag them into the right sequence. 🔢

  1. Show the final score on screen
  2. Use change score by 1 if the answer is right
  3. Use an if block to check if the answer is correct
  4. Ask the player a question
  5. Set score to 0 at the start of the program
  6. Create a variable called score

✍️ Complete the sentences about variables using the word bank below. 📝

A is a can . You should a before the . When a a , you use the to the .

doneyou now the ! Every app on your , every on a , and every to while it . it is your , your , or the of in a , are the the . 🌟

Quiz time! 📝

Variables and Keeping Score — Quick Check

Question 1 of 5

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

What is a in a ?

Finished?

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