Python Basics
Learn Python as a small set of interacting models, not a catalog of methods.
Learning path
| Question | Page |
|---|---|
| How do names, objects, expressions, and imports work? | Basic Syntax |
| How should behavior be packaged and called? | Functions |
| How does a program choose a branch? | Conditionals |
| How does it consume an iterable or repeat until a condition? | Loops |
| When is self-similar decomposition useful? | Recursion |
| How is Unicode text represented and transformed? | Strings |
| Which mutable sequence should hold ordered values? | Lists |
| How are keys mapped to values? | Dictionaries |
| How do objects own state and behavior? | Object-Oriented Programming |
| How should files and paths cross the program boundary? | File pages |
Core mental model
- Variables are names bound to objects; assignment does not copy an object.
- Every object has a type, identity, and value.
- Mutability determines whether an operation changes an object or produces a new one.
- Iteration asks an iterable for values; it is not limited to numeric indexes.
- Exceptions communicate failures across call boundaries.
- Modules and packages create namespaces and reusable ownership boundaries.
Working rules
- Prefer clear data flow and small functions over clever expression density.
- Make mutation and I/O visible at boundaries.
- Use standard-library types and protocols before inventing wrappers.
- Add annotations to communicate contracts, then use tooling if enforcement is required; Python does not enforce most annotations by itself.
- Test behavior rather than copying interpreter output into notes.