Introduction: Odd & Even Quiz Game in Scratch
Are you eager to dive into Scratch coding and create a truly interactive math game that teaches core programming concepts while reinforcing basic arithmetic? You’ve come to the right place! In this Scratch quiz game tutorial, we’ll build an engaging Odd & Even numbers quiz—a classic math quiz game in Scratch that’s perfect for beginners and educators alike.
You’ll guide your players through random number challenges, where they’ll click Odd, Even, and Next buttons to respond and progress. Along the way, you’ll learn how to use random numbers in Scratch, operate with variables, implement decision logic, manage sprites and costumes, and create interactive feedback—all foundational elements of logic-building game design.
By the end, you’ll not only have a polished Quiz Game in Scratch to share with friends and students but also a deeper understanding of Scratch programming essentials.
Why Create an Odd & Even Quiz in Scratch?
- Reinforces Math Concepts
Players practice recognizing odd/even numbers on the fly—a great tool for reinforcing number sense. - Teaches Core Programming Logic
You’ll useif-else
logic, operators likemod
, and Boolean conditions—all key constructs in any programming language. - Engages with Interactive Design
Beautifully designed sprites, dynamic score updating, and key user feedback create a polished gameplay experience. - Builds Confidence in Scratch Development
Through this Scratch project step-by-step, you’ll navigate sprite setup, variable management, control blocks, and event sequencing—all while keeping students motivated. - Scalable and Fun
Want to add levels, timers, or sound effects later? This structure makes it easy to expand into a full-fledged logic game or interactive game in Scratch.
Scratch Code: Odd & Even Quiz Game in Scratch
Watch the full video tutorial here: https://www.youtube.com/watch?v=o-FEAKtsoa0
1. Environment Setup – Sprites, Backdrops & Design
1.1 Remove the Cat & Choose a Backdrop
- Open Scratch from scratch.mit.edu.
- Delete the default cat sprite by right-clicking and selecting delete.
- Click Choose a Backdrop, search for “light,” and select a simple, bright backdrop. This style keeps the interface clean and focused.
1.2 Add the Quiz Host: “Shasha”
- Click Choose a Sprite → Search for “Shasha”.
- Add your favorite pose, then open Costumes and pick the happier version for your game host.
1.3 Create Three Button Sprites
- Click Add Sprite, search “button,” and add one.
- Duplicate it twice so you have three buttons.
- Rename them in the Sprite List as:
- Odd
- Even
- Next
- Customize each:
- Odd → orange background, white border, white text
- Even → green background, white text
- Next → blue background, white text
- Select uniform color styles and shades to indicate interactivity.
These steps make your UI intuitive—students know exactly where to click and what each button does.
2. Variables & UI Display
Essential Variables
Go to Variables and create three variables:
number
– Stores the random integer to evaluate. Set as visible and large for readability.score
– Tracks correct answers. Visible.click button
– A hidden variable managing button-state logic (0 or 1).
Configuring Variables
- Set
number
to display in the center of the screen in large style. - Place
score
prominently at the top corner. click button
remains hidden—used only for internal logic.
Initialization on Start
In Shasha’s script:
when green flag clicked
hide [number v]
set [score v] to [0]
set [click button v] to [0]
This ensures a fresh start each time the game runs.
3. Coding the Host (“Shasha”)
Shasha guides the player and introduces each round.
- Greeting Sequence
when green flag clicked
say [Hello, my friend.] for 2 secs
wait 1 sec
say [Tell me if this number is odd or even. Press the right button.] for 3 secs
- Reveal Random Number
show variable [number v]
set [number v] to (pick random [1] to [100000])
This code sequence ensures Shasha greets players first, then displays the challenge.
4. Button Logic – “Odd” and “Even”
a. “Odd” Button Script
when this sprite clicked
if <(click button = 0) and ((number mod 2) = 1)> then
change [score v] by [1]
say [Wow! You are correct!] for 2 secs
set [click button v] to [1]
else
say [Sorry, you are wrong. This is an even number.] for 2 secs
end
b. “Even” Button Script
when this sprite clicked
if <(click button = 0) and ((number mod 2) = 0)> then
change [score v] by [1]
say [Wow! You are correct!] for 2 secs
set [click button v] to [1]
else
say [Sorry, you are wrong. This is an odd number.] for 2 secs
end
Why this works:
(number mod 2)
checks the remainder:0
= even1
= odd
- The
click button
variable prevents repeated clicks on the same round.
5. “Next” Button Logic
Controls progression to the next round.
when this sprite clicked
if <(click button) = 1> then
set [click button v] to [0]
hide variable [number v]
wait [1] secs
show variable [number v]
set [number v] to (pick random [1] to [100000])
else
say [Please give the answer to the current question, then press 'Next'.] for 2 secs
end
This button resets after an answer and ensures pacing and order in gameplay.
6. Putting It All Together
Game Flow Recap
- Click green flag → reset variables and reset the board.
- Shasha greets the player, prompt appears.
number
variable is displayed and a random number appears.- Player clicks Odd or Even:
- Correct → score +1, feedback,
click button
= 1 - Incorrect → feedback,
click button
= 1
- Correct → score +1, feedback,
- Player clicks Next:
- Moves on if
click button
= 1 - Shows error if
click button
= 0
- Moves on if
This full sequence forms a tight Scratch number guessing game.
7. Testing & Debugging
Test several scenarios to ensure the logic is solid:
- Clicking Next before answering should prompt you to answer first.
- Score shouldn’t increase for wrong answers.
- Button state resets each round.
If something’s broken, add a test line like:
say [DEBUG: click button = (click button)] for 2 secs
Use this to verify internal state quickly.
8. Additional Features & Enhancements
Explore possibilities to elevate your project:
- Difficulty Levels
Offer range options (1–20, 1–1000, 1–1,000,000) with choices upfront. - Countdown Timer
Add atimer
variable and countdown sequence for urgency. - High Score Tracking
Use cloud variables for cross-session memory. - Visual & Audio Feedback
Add sound effects for correct/wrong answers and sprite animations like confetti. - Multiplayer Mode
Two-player alternating turns with alternating score counters. - Broadcast Events
Convert green flag sequences into broadcasts likestart
andnext question
. - Accessibility
Larger fonts, clear color contrast, and engaging colors for younger learners.
Conclusion
Congratulations—you’ve built an interactive, logic-driven Scratch quiz game from scratch! You learned to:
- Create sprites and customize costumes
- Manage variables and UI state
- Use
mod
logic for odd/even detection - Handle event-driven sprites and interactive buttons
- Prevent invalid input with flow control using
click button
- Provide dynamic feedback and progression
By watching the video and referencing this detailed blog, you now have both the why and how to build logic games with Scratch. Keep experimenting—add timers, layer in sound, or introduce multiplayer to expand your skills!
If you loved this Scratch project,
- Don’t forget to check out the full video tutorial by Kodex Academy here: Quiz Game to Identify Odd and Even Numbers | Kids Coding Project
- Like, comment & share the video
- Visit kodexacademy.com
- subscribe to the Kodex Academy YouTube channel for deeper Scratch content.
Happy coding with Kodex Academy! 🚀