New programming concepts
Variable and else if
A named place where a program stores information. Here, answer stores 1, 2, or 3.
A second condition to check when the first condition was false.
The final path when none of the earlier conditions were true.
Why store the number? The program must remember the random result while it checks which picture to show.
Try it here
Ask a yes-or-no question
Think of a safe, playful question.
Answer: not sure.
MakeCode steps
Build the three-way choice
- 1
- 2
Make a variable
Open Variables, select Make a Variable, and name it answer.
- 3
Save a random result
Inside on shake, set answer to pick random 1 to 3.
- 4
Add three paths
Add if / then / else. Use the plus button to add one else if path.
- 5
Build the conditions
If answer = 3, show Yes. Else if answer = 2, show No.
- 6
Use the final else
In else, show the Meh face. If the answer is not 3 or 2, it must be 1.
- 7
Trace before testing
Pretend answer is 2. Point to every block the program checks. Then test with the simulator.
Debug one path at a time
Temporarily set answer to 3, then 2, then 1 instead of using random. Confirm that every path works. Restore pick random 1 to 3 when finished.
For the teacher
A calm 60-minute plan
Recall
Roll a random number from 1 to 3.
Human variable
A student holds a card named answer.
Guided build
Complete one branch at a time.
Trace and debug
Force 3, 2, then 1.
Play and explain
Ask questions, then name the path used.
Keep the questions safe
Use playful, low-stakes questions such as “Will we read a story today?” Remind learners that a random toy cannot predict real events or make important decisions.
Before you finish