In this lesson, we will create an interactive math quiz game using Scratch.
A sprite will ask random addition questions, and the player will earn or lose points based on their answers.
A timer will limit the game duration, making it more exciting and challenging.
This lesson helps students understand variables, random numbers, loops, conditions, scoring, and timers in Scratch.
What Students Will Learn
How to create variables to store numbers, answers, score, and timer
How to generate random numbers using the pick random block
How to ask questions using ask and wait
How to join text and variables to create a question
How to use conditions with if then else
How to increase or decrease score based on player input
How to use forever loops to repeat actions
How to implement a countdown timer
How to stop the game when a condition is met
Creating Variables
Create variables for the game:
number 1 → first number in addition
number 2 → second number in addition
correct answer → sum of number 1 and number 2
score → to track points
timer → to control game duration
Generating Random Numbers
Under when green flag clicked:
Set number 1 to pick random 1 to 10
Set number 2 to pick random 1 to 10
Explanation: Random numbers ensure every question is different
Calculating Correct Answer
Set correct answer to number 1 + number 2
This value is used to check the player’s input
Asking the Player a Question
Use ask and wait from Sensing
Create a complete question using join blocks:
“What is ” + number 1 + “ + ” + number 2
Player types the answer, which is stored in the answer block
Checking the Answer
Use if then else block from Control:
Condition: answer = correct answer
If correct:
change score by 1
say “Correct! Well done.”
Else:
change score by -1
say “Incorrect, try again.”
Repeating Questions Continuously
Wrap the ask and check answer logic inside a forever loop
This ensures new questions appear continuously until the game ends
Adding a Timer
Create a timer variable
Set timer to 60 (seconds) under when green flag clicked
Use a forever loop to:
change timer by -1
wait 1 second
Explanation: Decreases timer every second
Stopping the Game When Time Runs Out
Inside the timer loop, add an if block:
Condition: timer ≤ 0
Action: stop all
Explanation: Stops the game automatically when the time is up
Scoring and Feedback
Correct answers increase the score by 1
Incorrect answers decrease the score by 1
The sprite provides interactive feedback using say blocks
Advanced Ideas for Students
Add subtraction, multiplication, or division questions
Adjust the timer for a faster or slower game
Add a win condition if the score reaches 10 or 15 before time runs out
Include sound effects or animations to make the game more fun
Make the questions more challenging by increasing the range of random numbers
Summary of What Students Learned
How to create and use multiple variables
How to generate random numbers
How to ask questions using ask and wait
How to join text and variables
How to check answers using if then else
How to increase or decrease score
How to use loops to repeat actions
How to implement a countdown timer
How to stop the game when a condition is met
Task for Students
Create your own math quiz game:
Include addition, subtraction, multiplication, or division
Adjust timer and scoring rules
Add interactive feedback like sounds or animations
Include a win or lose condition to make the game more exciting
Challenge yourself by making the questions and timer faster
Report
There was a problem reporting this post.
Block Member?
Please confirm you want to block this member.
You will no longer be able to:
See blocked member's posts
Mention this member in posts
Invite this member to groups
Message this member
Add this member as a connection
Please note:
This action will also remove this member from your connections and send a report to the site admin.
Please allow a few minutes for this process to complete.