← the wiki

Variable

A labeled box in the computer's memory that stores one value you can use and change later.

A variable is a labeled box: age = 30 puts 30 in a box labeled age, and from then on the label stands for whatever is inside. Assign again and the old value is replaced — the box holds one thing at a time.

Variables are how programs remember: the user's name, the score, the running total. Every program you'll ever write is, at some level, boxes being filled, read, and updated.

The best way to make it stick: watch it run. Start an interactive lesson →