Python tutorials and worked examples
Write reliable Python for data and AI: functions, collections, files, debugging and complete small projects.
Files and structured input
Read records incrementally and validate input contracts.
Read large CSV files in Python without loading every row
Stream a CSV with DictReader, validate malformed records and calculate an exact total while keeping only the current record and running counters.
tutorial · 4 min read
Debugging and exceptions
Trace failures to their causes and verify repairs.
Read a Python traceback and repair the failing assumption
Trace a KeyError through three function calls, identify the broken input contract and verify a repair without swallowing unrelated exceptions.
troubleshooting · 4 min read
Python environments
Select interpreters and reproduce project dependencies.
Python virtual environments with uv: select and verify the interpreter
Create an isolated Python environment with uv, bind package operations to that interpreter and verify isolation before diagnosing import failures.
tutorial · 4 min read
Collections and copying
Reason about references, mutation and the structure of your data.
Python shallow copy vs deep copy: trace a nested-data bug
Follow a nested dictionary through assignment, shallow copying and deep copying, then choose the right copying boundary for a data workflow.
troubleshooting · 4 min read
Functions and arguments
Understand calls, defaults and the state a function retains.
Python mutable default arguments: why state survives between calls
Reproduce a shared-default bug, repair it with a sentinel, and distinguish a fresh collection from intentional accumulation.
troubleshooting · 4 min read
Python projects
Combine language fundamentals into complete, testable programs.
Python projects for beginners: three small programs with complete code
Build three beginner Python projects with complete code: a study tracker, quiz report and CSV stock checker. Check the output, then extend each one.
project · 9 min read
Learning Python for AI
Choose the foundations needed for numerical and modeling work.
Python for machine learning and AI: what to learn first, and what to skip
The Python you need for machine learning, in order: core language, files and testing, then NumPy, pandas, Matplotlib and scikit-learn, plus what you can safely leave for later.
learning path · 8 min read