Reference · living document
Canonical definitions used across every lesson in this workspace.
python3 shell. Evaluates one line at a time, prints results back. Good for quick checks, not for real scripts..py file run top-to-bottom with python3 file.py.: (after if, for, def, etc.), followed by consistently-indented lines. No braces — the whitespace itself delimits the block.f, e.g. f"{name} is {age}" — expressions inside { } are evaluated and interpolated inline. The standard way to build strings with embedded values.[1, 2, 3]. Zero-indexed. The most common container — pandas Series is essentially a labeled list.{"key": value}. Keys must be hashable (strings, numbers, tuples). Insertion-ordered since Python 3.7. A DataFrame row is conceptually a dict.(1, 2) or 1, 2. Can't be changed after creation. Used for dict keys, function return values, and DataFrame index entries.items[0] (first), items[-1] (last). Works on lists, tuples, and strings. Zero-based.items[start:stop]. The stop index is excluded. Omit start or stop to go from the beginning or to the end.[expr for x in iterable]. Optionally filtered: [expr for x in iterable if cond]. The idiomatic Python replacement for map/filter patterns.x, y = (3, 5). Works with any iterable of the right length.s[0], s[1:3]) since a string is a sequence of characters — just an immutable one.with obj as name: that guarantees setup/cleanup around the block — most commonly with open(path) as f:, which closes the file automatically even if an exception occurs inside.import csv) that reads each row as a dict keyed by the header row, and correctly handles quoted fields containing commas — unlike hand-rolled line.split(","). All values come back as strings; you convert types yourself.