The Offender Engine Book

Learn to program — Lua & Python, right here

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

Loops

The reason programming beats a calculator: doing a thing many times costs one sentence. Lua counts with for i = 1, 5 do … end; Python walks a range with for i in range(1, 6): — note Python's range stops before its second number, which trips up everyone exactly once.

Task: print the squares of 1 through 5, one per line: 1, 4, 9, 16, 25.

goal output: 1 4 9 16 25