The big ideaA quiz asks, keeps the answer in a box, and uses if else to reply.
How it works
A quiz has three jobs: it asks, it checks, and it replies.
An ask block shows a question and waits. Whatever is typed goes into a box called answer.
An if else block looks in the box and picks one path or the other, like a fork in the road. A say block shows the reply.
A quiz that says yes to everything checks nothing, so every answer needs a check.
What happens when Ana plays.
Example 1: A right answer
Ana types Mars.
The answer box holds Mars, so the if path runs.
The quiz says "Yes! Mars is the red planet!"
Example 2: A different answer
Ana types banana for fun.
Banana is not Mars, so else runs.
The quiz says "Not quite. The answer is Mars."
Example 3: The quiz that checked nothing
Teo's first try was: ask the question, then say Correct!
It never looked in the box, so Ana typed banana and it said Correct!
The mix-up to fix: add an ask block, a box, and an if else to check.
Example 4: Three jobs
Each question in a quiz has an ask, a check and a reply.
A quiz of 3 questions has 3 × 3 = 9 jobs.
Each job is done by its own block.
Words to know
ask block
Shows a question and waits for a typed answer.
answer box
The variable that holds what was typed.
if else
Picks one path or the other.
say block
Shows a reply.
Watch out
A quiz must wait for the answer before it replies.
Else means anything different, so it catches every wrong answer, even a silly one.
Say shows a reply. It does not check anything.
A quiz that says yes to every answer is not a real quiz.
Try it
In Teo's quiz, Ana types Mars. What does the quiz say?
Ana types Venus. What does the quiz say?
Which block does the checking: ask, say or if else?
Does a quiz reply before an answer is typed?
Teo's first quiz said Correct! to banana. What was the mix-up to fix?
Answers: 1. Yes! · 2. Not quite. · 3. if else · 4. No · 5. It never checked the answer
Try at homePretend to be a quiz. Ask a grown-up a question you know, like what colour is the sky? Listen to the answer. Then say: if the answer is blue, say yes. Else, say try again. Then swap roles, and let them be the quiz.
For grown-upsDo the Mission: pretend to be a quiz. Ask a question you know, listen to the answer, then say: if the answer is blue, say yes, else say try again. Then swap roles.
Open these notes on screenScan the code, or go to tutorpip.com.