The Offender Engine Book

Learn to program — Lua & Python, right here

1. Say hello 2. Variables 3. Loops 4. Functions

Variables

A variable is a name for a value, so you can use it twice without typing it twice. Lua introduces one with local; Python just assigns. Both languages will happily do arithmetic with them: * multiplies, + adds.

Task: a room is 6 metres wide and 4 metres deep. Store the width and depth in variables, multiply them, and print the area — the single number 24.

goal output: 24