What if your program could ask you a question, remember your answer and then decide what to do with it? Type in a mark, and Scratch tells you whether it is a pass. Type in an angle, and a spaceship flies that way. That is input from the keyboard, and it is what makes programs truly interactive.

Image source: File:Scratch 3.0 editor.png (Wikimedia Commons)
In this post:
- Asking questions with ask and wait and using the answer
- Variables: what they are, how to make one, number and text values, set and change
- Operators: join, maths, comparisons and and/or/not
- Making choices with if, if-else and repeat until
- A pass-mark simulator, three Scratch projects including a space game, and a quiz
Asking a question
ask [What’s your name?] and wait (Sensing) makes the sprite ask the question and shows a box for typing. The program waits until you press Enter. Whatever you typed is stored in the answer block, which you can then use anywhere, for example say (answer). The Sensing category also has touching [ ]?, which checks whether the sprite is touching another sprite, the edge or the mouse.
Stuck on a block? Right-click it and choose Help (or open the Tutorials button at the top of the editor) for an explanation and examples.
Variables
A variable is a named store in the computer’s memory that holds one value, which can change while the program runs. Think of a labelled box: the label is the name (score), and what is inside is the value (7). The answer block changes every time someone answers a new question, so it is smart to copy it into your own variable straight away.
| How to… | Do this |
|---|---|
| Make a variable | Click the Variables category → Make a Variable, type a clear name (e.g. mark) and choose For all sprites or For this sprite only. |
| Give it a value | set [mark] to (answer). Also use set at the start of a game, e.g. set [score] to 0. |
| Add to it | change [score] by 1 (use −1 to subtract). |
| Show or hide it | Tick the box next to it to show its value on the stage, or use show variable / hide variable. |
Variables can hold numbers (like 72 or 3.5) or strings (text, like Ravi or Grade A). Scratch works out which is which for you, but you should still know the difference: you can do maths with numbers, but not with names!
Operators (green)
| Type | Blocks | Example → result |
|---|---|---|
| Join (text) | join [ ] [ ] | join (answer) [ Is a pass!] → “72 Is a pass!” |
| Maths | + − * / | (score) * 2, (total) / 5 |
| Comparison (relational) | > < = | (mark) > 50 is true when the mark is 72 |
| Logic | and, or, not | <(mark) > 50> or <(mark) = 50> is true for 50 and above |
Making choices: if, if-else and repeat until
- if <condition> then runs the blocks inside only when the condition is true.
- if <condition> then … else … runs the first set of blocks when it is true and the second set when it is false. This is the flowchart decision diamond in Scratch!
- repeat until <condition> keeps repeating the blocks inside until the condition becomes true, for example repeat until <touching edge?>.
Explore: is it a pass?
This project asks for a mark, then uses if-else with an or condition and the join block to say whether it is a pass. Try it below, then try the simulator underneath, which uses exactly the same script.
Scratch project: Pass Mark Demo (2026-05-06) by kunge.
Try it: test the pass-mark program
Click the green flag, type a mark and press Enter. Test a pass, a fail and exactly 50.
when green flag clicked
ask [Please enter a mark] and wait
if <<(answer) > 50> or <(answer) = 50>> then
say (join (answer) [ Is a pass!]) for 10 seconds
else
say (join (answer) [ Is a fail !]) for 10 seconds
end…
🐱
answer = (empty)
The next version goes further. A variable called numMarks counts how many marks have been entered (change [numMarks] by 1 each time), and a forever loop keeps asking for marks. A second variable, speedFactor, controls how many seconds each speech bubble stays up, so changing one number changes the speed of the whole program.
Scratch project: Pass Or Fail – Upgraded (infinite repetition, using variables) by kunge.
Challenge: the space game
Here is a bigger project to explore, built for a classic programming challenge: steer a spaceship to a planet by typing an angle. Click the green flag. The score (Planets Destroyed) is set to 0 and the planet and rocket move to random places. Then the rocket asks you to Set bearing to …. A bearing is an angle measured like a compass: 0 is straight up, 90 is right, 180 is down and 270 is left. Your answer is stored in the variable bearing, and the rocket flies in that direction until it touches the edge. If it touches the planet on the way, the score goes up by 1 and the planet explodes; if not, the rocket says “I’ve Failed” and the score goes back to 0.
Scratch project: Planet destroyer by kunge.
Look inside to find: a set block for the score, ask and wait, a variable set to the answer, repeat until <touching edge?>, an if with touching Planet2?, and broadcasts (initialization, done moving, Start Game, Destroy Planet) that coordinate the two sprites.
Watch: the ask block and variables
This tutorial shows how to use the ask block and explains why we store answers in variables.
Video: How to use “ask” block and why we need variables – Scratch Tutorial – Hardy Code Lesson – https://www.youtube.com/watch?v=6prWODHL0Ts
Activity: true or false?
Try it: is the condition true or false?
Work out whether each condition is true or false for the value given.
(mark) > 50 when mark = 50 | |
(mark) = 50 when mark = 50 | |
<(mark) > 50> or <(mark) = 50> when mark = 50 | |
<(age) > 11> and <(age) < 15> when age = 13 | |
<(age) > 11> and <(age) < 15> when age = 16 | |
not <(score) < 10> when score = 4 | |
(answer) = [Paris] when the answer typed is Paris |
Your challenge
- Make a quiz sprite that asks three questions, keeps a score variable, and says “You got (score) out of 3” at the end using join.
- Make a sprite ask “What is 7 × 8?” and repeat until the answer is 56, saying “Try again!” after each wrong answer.
- In groups of three or four: remix the space game to add a lives variable, so a player has three tries before the game is over. Present your solution to the class.
Self-check quiz
Click the best answer. You get feedback straight away; only your first click counts towards your score.
1. Where is the text you type after an ask and wait block stored?
2. A variable is…
3. Which block gives a variable a value, such as 0 at the start of a game?
4. What does join [Hello ] (answer) give if the answer is Asha?
5. Which condition is true for a mark of 50 or more?
6. What does repeat until <touching edge?> do?
Related posts on islandclass.org
- Scratch Programming – Creating interactive sprites
- Scratch – Selection, Sensing, Repetition, Outputting Results. – class notes
- Catch by Coordinate – Scratch Game Assignment – a coordinate-guessing game assignment
- 25-05-12 ICT 3N – Creating Interactive Sprites – Live Class – class recording
- Input Sensing, Finding a pass Mark Form 3A – 2026-05-06_13-26-38 – class recording of the pass-mark demo
- How to Tolerate a guess withing a certain range using the abs Function (3N) – 2026-05-08_10-03-41 – class recording on accepting a guess that is close enough
For later, in Forms 4–5 (CSEC IT): these go deeper and are for when you reach CSEC Information Technology.
- Variables, Constants and Data Types: Integer, Real, Character, String and Boolean
- Operators in Algorithms: Arithmetic, Relational and Logical Operators, Truth Tables, MOD and DIV
Next: Scratch: Building an Interactive Game
Syllabus link: Forms 1–3 ICT curriculum, Module 5, Objective 5.15 – develop a program that accepts input from the keyboard.
Attributions to media used in this post:
- Scratch 3.0 editor.png – Screenshot: Obscure2020; Scratch is by MIT and other contributors – CC BY-SA 2.0 (via Wikimedia Commons)
- Video: How to use “ask” block and why we need variables – Scratch Tutorial – Hardy Code Lesson (YouTube)
- Scratch project: Pass Mark Demo (2026-05-06) – kunge (Scratch)
- Scratch project: Pass Or Fail – Upgraded (infinite repetition, using variables) – kunge (Scratch)
- Scratch project: Planet destroyer – kunge (Scratch)
Updates
2026/10/21
– Fixed the activity code so its buttons keep working.
© 2026 Vedesh Kungebeharry. All rights reserved.