
Python strings
A string never changes after it is made.
24 topics, each on a single A4 page you can print, pin above your desk or keep open next to your editor. 1263 examples in all, and every one is run against Python 3.13 before a sheet is published, so the result printed next to it is the result you'll get. Each sheet ends with the mistakes people often make.

A string never changes after it is made.

A list keeps items in order, and you can change it.

A tuple keeps values in order and cannot change after you create it.

A dictionary (dict) stores each value under a key, so you can find a value quickly by its key.

A set holds each value only once, in no fixed order.

seq[start:stop:step] takes the items from index start up to, but not including, index stop, as a new list, string or tuple.

A comprehension is a for loop, written in one line, that builds a new list, set or dict.

An f-string has f before the quotes.

A loop runs the same lines again: once for each item (for), or as long as a condition is true (while).

A function is a named block of code that you can run again and again.

A class is a plan for a kind of thing: what data it holds and what it can do.

A Path is only a name until you read or write it, and text files should always be opened with encoding="utf-8" (the encoding is how letters are stored as bytes).

JSON is a plain-text format for data (objects, lists, strings, numbers, true/false and null) that almost every language and web API can read.

When an error happens, Python passes it back up through the function calls until an except for its class catches it.

The collections module gives you ready-made containers for jobs that plain lists and dicts make awkward: counting, grouping, queues and small records.

A date is a day, a datetime is a day plus a clock time, and a timedelta is a length of time: subtract two datetimes and you get a timedelta.

A regular expression is a pattern that describes text.

Every tool here is lazy: it makes one item at a time, only when a loop asks for the next item.

A type hint labels the type a value should have.

argparse reads the words typed after your script's name, turns them into values of the right type, and writes the help and error messages for you.

pip installs packages that other people wrote.

A NumPy array is a grid of numbers of one type that you can do maths on all at once, with no loop.

pandas works with tables of data, like a spreadsheet inside Python.

Matplotlib draws charts.
Free to share, not to sell. Print them for yourself, your class or your team, and share the files as they are. Each sheet links to its runnable version on this site, where you can try every example in the browser.