Ibnovate Scratch Creators
⏱ 60 minLive session

Session 8 — Ask, Answer & Build a Quiz

Duration: 60 min · Format: live online

What you'll learn: by the end, you can make a sprite ask a question and wait, read the player's typed answer, check it with an if block, and use a score variable to build a working 3-question quiz — tying together the two big ideas of Unit 2: decisions and variables.

Soft skill focus — Communication

Today you'll also grow Communication. A quiz only works if the sprite's question is worded so clearly the player knows exactly how to answer.

What you'll need


Hook

Let's think about this:

Here's what's coming: today your sprite gets ears. It will ask a question, wait while you type, then check if you're right — and keep a score. By the end of the hour you'll have a real quiz game anyone can play.


Teach — Ask, wait, and the answer reporter

Look at this diagram and follow the arrows from "ask" to "answer" to "check":

A quiz: the sprite asks a question, waits for the player's answer, then checks if it is correct

Here's how it works:

Build this:

1. From Sensing (cyan), drag out ask [What is your name?] and wait and click it. A text box appears on the stage — type a name and press Enter.

2. From Sensing, tick the checkbox next to answer — it appears on the stage showing exactly what you typed. That's where the player's reply is stored.

3. From Looks (purple), build say (answer) for 2 seconds — drag the rounded answer block into the say block's white slot. Run it: ask, type, and the sprite repeats your answer back.

Now your script reads:

when green flag clicked
ask "What is your name?" and wait
say answer for 2 seconds

⚠ Watch out: answer only holds the most recent reply. As soon as the next ask runs, the old answer is replaced. If you need to keep something, check it (or save it) before the next ask.

Think about it: after you type your name, where does Scratch keep it? (In the answer reporter.) And what does and wait mean? (The script pauses until the player replies.)


Teach — Check the answer and keep score

Asking is only half a quiz — now you check the answer and reward a right one. This is where Unit 2's two ideas meet: a decision (if) and a variable (score).

Build this:

1. In Variables (orange-red), click Make a Variable, name it score, and drag out set score to 0 for the top of the script — every game starts at zero.

2. From Sensing, add ask [What is 2 + 2?] and wait.

3. From Control (orange), drag out if … then. From Operators (green), drop ( ) = ( ) into its hexagon slot. Into the left side drop the answer reporter; type 4 on the right. It now reads if <answer = 4> then.

4. Inside the if, put change score by 1 (Variables) and say [Correct!] for 1 seconds (Looks).

Now your script reads:

when green flag clicked
set score to 0
ask "What is 2 + 2?" and wait
if <answer = 4> then
  change score by 1
  say "Correct!" for 1 seconds

Press the green flag. Type 4 → the sprite says Correct! and the score jumps to 1. Run again and type 5 → nothing happens (the if was false).

Add the "wrong" path. Swap the if for if … then … else and put say [Not quite!] for 1 seconds in the else part, so every answer gets a reply. Now the sprite reacts to both right and wrong.

Think about it: where does the answer go in the check? (Into one side of the green = block.) What makes the score go up only when they're right? (The change score by 1 sits inside the if — it runs only when the check is true.)


Activity — Build a 3-question quiz

Build a real, playable quiz. Do the first question, then add two more.

  1. Open a new project at Scratch. Start the script with when green flag clickedset score to 0.
  2. Question 1: add ask [ ] and wait with your own question, then an if <answer = [ ]> then … else that does change score by 1 + say "Correct!" on the true side and say "Not quite!" on the else side.
  3. Questions 2 and 3: snap on two more ask + if–else pairs, each with a new question and its own correct answer.
  4. Show the final score: at the very end add say (join [You scored ] (score)) for 3 seconds (the join block is in Operators, green) — or just tick the score checkbox so it shows on the stage.
  5. Make it yours: pick a theme (animals, football, maths), swap the backdrop, and have the sprite say "Ready?" before the first question.

As you build, check: is the score block inside the if? What happens if you spell the answer differently — does it still count?


Check yourself

Try these:

  1. What does ask [ ] and wait do? → It shows a question with a text box and pauses the script until the player types a reply and presses Enter.
  2. Where is the player's reply kept? → In the answer reporter (Sensing) — it holds the most recent thing typed.
  3. Why does change score by 1 go inside the if? → So the score only goes up when the check is true — i.e. when the answer is correct.

Wrap-up


Tips & extra challenges

Vocabulary

Term Meaning
ask … and wait Sensing block that asks a question and pauses for a typed reply
answer A reporter holding the player's most recent typed reply
= (equals) An Operator that checks whether two things are the same
if … then A Control block that runs its blocks only when a check is true
Variable A named box that remembers a value, like score

Resources

Practice set

Practise on your own with these tasks to build up a quiz. Work them easy → hard. Answers follow each arrow.

1. Name that block. Which block makes the sprite ask a question and wait for a typed reply? → ask [ ] and wait (Sensing, cyan).

2. Where's the reply? After the player types, which block holds what they typed? → The answer reporter (Sensing).

3. Colour clue. You need the = block to compare the answer. Which colour palette is it in? → Green — Operators.

4. Predict. The check is if <answer = 4> then → say "Yes!". The player types five. What happens? → Nothingfive does not equal 4, so the if is false and say doesn't run.

5. Make it (build task). Build a script that asks "What colour is the sky?" and says "Correct!" only if the answer is blue. → ask "What colour is the sky?" and wait → if <answer = blue> then → say "Correct!" for 1 seconds.

6. Keep score (harder). Add scoring so a correct answer makes score go up by 1, starting from 0. Where must set score to 0 go, and where must change score by 1 go? → set score to 0 goes at the top (before the questions); change score by 1 goes inside the if, so it only runs when the answer is correct.

Going deeper (optional)

Optional — for when you have a working quiz and want to make it fairer and smarter.

Exact matching is strict. Because answer = 4 needs an exact match, real quizzes get tripped up by spaces and capital letters — Blue, blue and BLUE all look "wrong" to a strict check. Programmers fix this by cleaning the answer first (lowercasing it, trimming spaces) or by accepting a few spellings with or. Even just knowing this trap exists makes you a better tester of your own game.

One answer box, reused. There is only one answer reporter for the whole project, and every ask overwrites it. That's why you must check each answer right after its question, before the next ask wipes it. If you wanted to remember all three replies, you'd copy each into its own variable — a neat link back to last session's work on variables.

Common mistakes & fixes

If it's not working, check these:

What's next

Session 9 — Catch the Falling Apples: the start of Unit 3 — Build Real Games. You'll put decisions, variables and the x–y grid together to build your first full game — apples fall from the top of the stage and you move a basket to catch them for points.

Ibnovate · Build · Innovate
Type to search · Esc to close
Welcome back
Sign in to continue building.
Accounts are created by Ibnovate — ask your instructor for your login.
🔒