Python programs operate on objects with explicit input, ownership and failure contracts.
Learning roadmap
This section contains 31 written lessons or quiz banks. Programs are verified on CPython 3.14.6. Standard-library lessons target 3.11+ syntax; lessons using data, web, machine-learning or testing packages state their tested dependencies separately. Framework programs use local test clients, not a deployed service. Read the stated limits before adapting a fixture into an application.
Sequence and key ownership
Read the contract, run its program and inspect the failure case.
- Python lists: slicing copies the outer sequence, not nested objects
- Python tuples: immutable containers can still contain mutable state
- Python dictionaries: insertion order and duplicate-key replacement
- Python sets: membership and deduplication do not preserve input order
- Python sorting: stable keys, independent output and explicit tie rules
Text and numeric representation
Read the contract, run its program and inspect the failure case.
- Python strings and bytes: reject decoding errors before parsing records
- Python Decimal money: parse decimal text and choose rounding explicitly
Copies, text and rolling collections
Read the contract, run its program and inspect the failure case.
- Python shallow and deep copies: preserve aliases deliberately
- Python Unicode normalization: equality is not visual identity
- Python Counter and deque: counts, queues and bounded history
- Python zoneinfo and fold: two instants can share one clock label
Buffer and key contracts
Read the contract, run its program and inspect the failure case.
- Python memoryview: shared buffers and explicit release
- Python hash and equality: immutable dictionary keys
- Python Enum: parse wire values into a closed state set
Factories, record shapes and sorted positions
Read the contract, run its program and inspect the failure case.
- Python defaultdict: missing-key reads can create state
- Python namedtuple records: immutable fields can still hold mutable objects
- Python bisect: binary position search does not make list insertion logarithmic
Numeric buffers, explicit order and iterator composition
Read the contract, run its program and inspect the failure case.
- Python array: fixed-width numeric storage is not a portable wire encoding
- Python OrderedDict: explicit reordering differs from insertion order
- Python itertools: adjacent groups and shared iterator consumption
Layered settings and wire bytes
Read the contract, run its program and inspect the failure case.
- Python ChainMap: live configuration layers versus an owned snapshot
- Python struct: a fixed-endian receipt record with exact byte length
Exact ratios, aliases and local-clock ambiguity
Read the contract, run its program and inspect the failure case.
- Python Enum aliases: iteration and member lookup have different domains
- Python Fraction: exact ratios require an exact input representation
- Python ZoneInfo: classify unique, repeated and missing local times
Mapping views and snapshots
Read the contract, run its program and inspect the failure case.
Mutable bytes and snapshots
Read the contract, run its program and inspect the failure case.
Mapping alias ownership
Read the contract, run its program and inspect the failure case.
Text and numeric import boundaries
Read the contract, run its program and inspect the failure case.
- Python UTF-8 imports: reject malformed bytes and unexpected BOMs
- Python Decimal Inexact trap: reject fractional minor units
- Python dictionary union: new mapping, shared nested values
Continue learning
Move between tutorial, collections, advanced material and practice using the subject tabs. The sidebar changes with each section; related examples keep one canonical lesson URL.
