Skip to content
Hi, Bot

Hi, Bot · First Principles · Phase 1: Logic, functions, symbols

Lesson 3 of 48

Variables and state

A box with a name, whose contents change while the procedure runs.

State is what makes a program hard. The same code with different state does different things, which is why “it works on my machine” is a sentence that exists. Naming the state and knowing when it changes is most of debugging.

Do this

Build a small project with a score that stays correct after every possible sequence of actions — including the awkward ones somebody would try in order to break it.

The question that unlocks the next lesson

Two lines of code are identical but produce different results on two runs. What must be different?

  • AThe language version
  • BThe state those lines read from or write to
  • CNothing — identical code always behaves identically
  • DThe order the file was saved in

Start at lesson 1 and work up to this one

48 lessons, one a day. Answer each lesson's question correctly and the next one opens immediately — nothing here is unlocked by waiting.

By submitting, you agree to our Terms and Privacy Policy.