A free book, written in public
Python for Humans
Learn to code by hand, at human pace, with Python running right beside the page.
Free to read. Nothing to install until chapter 11. 2 of 24 chapters posted so far.
Try it now. Click below, type your name in quotes, and press Enter:name = 'Ada'
Contents
Chapters go up here as they're written. Each post is a draft, with its version and date on the page.
Part I
Thinking in code
Python runs in the page, so there's nothing to install. Strings, lists, loops, dictionaries and functions, all on the complete works of Shakespeare.
- 1 Getting started
- 2 Variables, print, input
- 3 Types
- 4 Reading a File
- 5 Lists
- 6 Loops
- 7 Conditionals
- 8 Dictionaries
- 9 Functions
- 10 Under the hood
Part II
From the REPL to programs
Install Python and write programs you keep. Errors, tests, files, modules, packages, the web from both sides, and classes.
- 11 Keeping your work
- 12 Errors and debugging
- 13 Testing
- 14 Files and the filesystem
- 15 Modules and several files
- 16 Packages and uv
- 17 The web in one chapter
- 18 Classes
- 19 The other side of the web
Part III
Capstones
Write a program that writes new Shakespeare, a crude ancestor of the language models. Then find and fix the bugs in code someone else wrote.
- 20 The word-prediction generator
- 21 Capstone menu
Part IV
Coding with AI, as a human
Work with an AI as the person in charge, and where to go next.
- 22 Working with an AI, as a human
- 23 Where next
Who am I?
Hi, I'm Will Vincent. I'm a Python Software Foundation Fellow, a former board member of the Django Software Foundation, author of Django for Beginners, and co-host of the Django Chat podcast.
I've taught Python and web development to thousands of developers through my books, tutorials and courses. I believe in learning the fundamentals properly: understanding how code works, not just copying what an AI suggests.