New programming concepts
If / else decision
If / else lets a program choose between two paths. It checks a condition. If the condition is true, it follows the first path. Otherwise—else—it follows the second.
A question with a true or false answer.
A comparison asking whether one number is larger.
The program selects which path to follow.
Try it here
Move from dark to bright
DarkBright
60 is not greater than 100. The screen is clear.
MakeCode steps
Build the decision
- 1
- 2
Add a decision
From Logic, place if / then / else inside forever.
- 3
Build the condition
Add a > comparison. Put light level on the left and 100 on the right.
- 4
Choose the true path
Inside if, add show icon and choose the sun.
- 5
Choose the else path
Inside else, add clear screen.
- 6
Test the threshold
Change the simulator light level. On the board, cover and uncover the LEDs. Adjust 100 if your room needs a different threshold.
Read the condition aloud
“If the light level is greater than 100, show the sun. Else, clear the screen.” Reading code aloud helps learners follow both paths.
For the teacher
A calm 60-minute plan
Human decision
If it is bright, raise a hand; else lower it.
Draw both paths
Use a paper true/false decision tree.
Guided build
Read each block aloud.
Test the threshold
Cover, uncover, and adjust.
Explain
Each team describes true and false paths.
Common misconception
The number 100 is not “correct” everywhere. It is a threshold chosen for the room. Testing and adjusting it is part of the engineering work.
Before you finish