The switch and the condition: the lamp
Section 4: ConditionsLesson 4.1 · ⏱ 8 min



- when Switch1 changes works every time we turn the switch on or off.
- if … else chooses between two ways: if the switch is on do this, otherwise do that.
📌 Another example: night mode
The switch changes the screen to night and day.



✍️ Practise
The challenge: the switch and the colours.
✍️ Practise here in the lesson✖ Close the labor open the lab in a new page ↗
🎯 Challenge yourself
Easy
The switch shows or hides the picture.
👀 Show the solution🙈 Hide the solution



Result: the picture disappeared.
Medium
The switch writes “On” or “Off”.
👀 Show the solution🙈 Hide the solution



Result: On ✅
Hard
A lock with two switches: it only opens if both are on.
👀 Show the solution🙈 Hide the solution



Result: one switch: locked. Both: open.

