First-edition codes from Chapter 1 (Idiomatic Python)