Lesson 28 · State machine

Advanced programming · 6 min · See the playlist on YouTube ↗

✓ You already watched this lesson

A traffic light doesn't ask a question; it has a state, and what it does depends on which of the three it's in. That's a state machine, and it's everywhere.

🎯 The challenge of this lesson

Add a fourth case, worth three, that sets the output to forty; then remove the If none and see what the program answers with a state that isn't in any branch.

Practise in the app

Read the written page for this lesson →

Stuck on this lesson?

Write your question and another student — or the teacher — will answer. Your email is never published: it is only used to let you know when someone replies.

Before being published, every message goes through an automatic filter that rejects bad language and any attempt to intimidate another person.

  • Loading the questions…