Build a simple scoring system in code
Be able to combine loops, conditions, and variables into a program that calculates scores.
Prerequisites
- BIdentifying and fixing bugsrequired
Everyday explanation
A simple scoring system needs three things you already know:
- a loop that runs the program again and again (forever),
- a condition that checks if something happens (if button is clicked),
- a variable that holds the score.
score = 0
forever:
wait 1 second
if button is clicked:
score = score + 1
update score display
Interactive
Build it in Python or Scratch: Create a button and a score display. Give the program the logic above. The button also needs a program: when clicked → update score.
The program is “done” when it counts correctly. Then you improve it: add a timer (if time > 60: stop), add a bonus button that gives extra points. Each improvement: build, test, fix.
Mastery means
- Builds a program with a loop, a condition, and a variable
- Explains what each part of the program does
Sign in to do the exercises and build your mastery up.
Sources
- Scratch Wiki (CC BY-SA 4.0) — CC BY-SA 4.0
- Scratch (MIT) — gratis — free web service; project CC BY-SA 2.0