Free Sample: Chapters 1 and 2
The whole of Part I — Chapter 1, Mathematical Concepts, and Chapter 2, Problem Solving — is yours to read, free, with nothing held back and no watermark. Twenty-six pages, typeset exactly as the printed book is.
Why these two chapters
Because they are the ones that make the rest of the book work, and they are the ones no other beginner’s book gives you.
Part I is almost all groundwork: a small, exact vocabulary for describing things (Chapter 1), and a method for taking a problem apart before you touch a keyboard (Chapter 2). Chapter 1 has no code in it whatsoever, and the Python in Chapter 2 arrives only at the end, once the problem has already been worked out on paper. Every later chapter leans on what is built here.
It is also the fairest possible sample. If the explanations in Part I land for you — if the wall clock makes modular arithmetic obvious, if Al-Khwarizmi’s golden principle changes how you look at a problem — then the same voice carries you through the remaining nineteen chapters. If it does not, you have lost nothing.
What is in the sample
Chapter 1 — Mathematical Concepts. Logic and the words that carry it. Sets. Integers and modular arithmetic, explained with a clock face. Variables. Functions as mappings, drawn as machines with an input and an output. Composition. Sequences and patterns, from a sunflower head. Counting. Algorithms. Graphs and trees. Binary numbers and how a decimal number becomes one. Boolean values. Hashing. Recursion, illustrated by Escher’s drawing hands.
Chapter 2 — Problem Solving. Al-Khwarizmi’s golden principle, and what it means to break a problem into steps that can be solved one at a time. A worked example — finding a word in a dictionary — taken from vague description to numbered procedure. Pseudocode. Then the translation from pseudocode into a first Python program.
Reading notes
- The sample is drawn from the same source as the book, so a handful of cross-references point forward into chapters that are not included — Chapter 1 refers to the computer model in Chapter 3, for instance. Those numbers are correct for the full book.
- Part I carries no Find the Bug exercises; those begin in Chapter 5, once there is Python to get wrong. All 445 of them are free on this site regardless of whether you have the book.
- The PDF is 6×9 inches, the book’s trim size. It reads comfortably on a tablet and prints on A4 or Letter without reflowing.
After the sample
If Part I did its job, Chapter 3 explains what a computer actually is, Chapter 4 introduces Python, and Chapter 5 is where the exercises start. The table of contents lays out the whole route.