Learn the Python AI engineers use daily: types, classes, generators, async calls, retries, config and secrets, tests, and a first FastAPI endpoint.
You have just joined acme-shop as its first AI engineer.
Variables, strings, and numbers A variable is a labelled box holding a value. You store a value once under a name and reuse the name.
List and dictionary comprehensions A comprehension builds a new list or dictionary in one readable line instead of a multi-line loop.
Functions and type hints A type hint tells readers and tools what type a parameter and return value should be.
A small class with state A class bundles data (state) and the functions that work on it (behaviour).
What a decorator does A decorator wraps a function to add behaviour without changing its code.
You have just joined acme-shop as its first AI engineer.
Variables, strings, and numbers A variable is a labelled box holding a value.
List and dictionary comprehensions A comprehension builds a new list or dictionary in one readable line instead of a...
Functions and type hints A type hint tells readers and tools what type a parameter and return value should be.
A small class with state A class bundles data (state) and the functions that work on it (behaviour).
What a decorator does A decorator wraps a function to add behaviour without changing its code.
Environment variables and .env files An environment variable is a value set outside your code, so secrets never live in...
Why async helps AI workloads A synchronous call blocks your program until it finishes.
httpx next to requests httpx is a modern HTTP client with the same simple style as requests, plus an async version.
When a notebook is the right tool A Jupyter notebook mixes code, output, and notes in cells you run one at a time.
pytest basics pytest finds functions named test_* and runs them. A test is an assertion about what your code returns.
A 15-line classification endpoint FastAPI is the web framework most AI services use.
You will classify acme-shop support tickets two ways, compare them with real numbers, speed the model path up with...
You now have the ai-lab kit with Ollama and llm.py, a ticket processor that reads 2,000 tickets with a generator, a...
Catching every exception with except Exception: hides the real failure and makes production incidents harder to debug.
Roles that use the skills in this module.
AI Engineer
MLOps Engineer
Platform Engineer
DevOps Engineer
Not a software engineer sheet. Every problem comes from real DevOps, SRE, Platform and Cloud interviews, from your first script to a system you build yourself.
Open the Coding SheetNo. Every lab runs on a free local model through Ollama. A hosted provider is an optional switch: you change three environment variables, and you pay per token, so estimate the cost first.
Most of the time in an AI call is spent waiting on the network or the model. Async lets your program start many calls and wait for them together, so total time shrinks. It does not speed up heavy computation.
Model APIs sometimes time out or return 429 or 5xx errors that clear in seconds. Waiting a little longer after each failure avoids hammering a struggling service. Retrying every error, though, hides real bugs, so only retry the errors that can recover.