AI ENGINEERING · PYTHON
Python for AI Engineers
Python is the language of AI work. This course takes a developer who already codes in Java or JavaScript to confident, modern Python: projects with uv, types and Pydantic, async, FastAPI, testing, NumPy and pandas, and the machine learning and PyTorch basics that AI engineer interviews still ask. 26 lessons, each with code you run in the browser and exercises that check your answer.
Part A · Python, properly
Everything a Java or JavaScript developer needs to write clean, modern Python.
- 1Set up Python the modern wayInstall Python the way working teams do in 2026: one tool, uv, that installs Python, creates a project, manages its virtual environment and locks its packages. Every step is mapped to npm and Maven, so a Java or JavaScript developer knows exactly what each file and command is for.
- 2Python for Java and JS developersThe Python you need when you already know Java or JavaScript: indentation instead of braces, dynamic but strong types, None and truthiness, == vs is, big integers and two kinds of division, f-strings, slicing, loops with enumerate and zip, and the one-line tricks Python code is full of.
- 3Lists, dicts, sets and tuplesThe four built-in collections for a Java or JavaScript developer: list costs (Big-O), dict lookups and defaults, sets for fast membership and dedupe, tuples as keys, comprehensions, Counter, defaultdict, deque, sorting with key=, and copy versus alias.
- 4Functions, closures and decoratorsHow Python functions really work for a developer coming from Java or JavaScript: default and keyword arguments, the mutable default trap, *args and **kwargs, functions as values, closures, and decorators. You will finish by writing the @retry decorator every LLM app needs.
- 5Classes and dataclassesPython classes for a developer coming from Java or JavaScript: __init__ and self, class vs instance attributes, @property, dunder methods, dataclasses (default_factory, frozen, order), inheritance with super(), composition, ABCs and Protocol. You will model the messages of a chat app.
- 6Type hints and PydanticType hints for a Java or JavaScript developer: list[str], dict[str, int], X | None, TypedDict and Literal, why Python never checks them, and how mypy does. Then Pydantic: validated models, clear errors, Field rules, JSON in and out, and validating an LLM's JSON reply.
- 7Errors, retries and context managersPython error handling for a Java or JavaScript developer: try/except/else/finally, catching the right exception, custom exceptions and raise from, EAFP, with statements, writing your own context managers, retries with backoff, logging, and turning LLM SDK errors into messages users understand.
- 8Iterators and generatorsPython iterators and generators for a Java or JavaScript developer: iter and next, what a for loop really does, yield, generator expressions, laziness and memory, lazy pipelines (read, clean, chunk), itertools (islice, chain, batched, groupby), yield from, and streaming LLM tokens into sentences.
- 9async and awaitAsync Python for Java and JavaScript developers: coroutines, the event loop, asyncio.run, running LLM calls concurrently with gather, timeouts, limiting concurrency with a Semaphore, streaming with async generators, and the two bugs everyone hits.
- 10Files, JSON, config and secretsRead and write files with pathlib and UTF-8, turn JSON into dicts and back, store datasets and logs as JSON Lines, read settings from environment variables and .env, and keep API keys out of Git and logs. You finish by totalling token usage per user from a JSONL log of LLM calls.
Part B · Python for data and serving
HTTP, FastAPI, testing, NumPy, pandas and documents: the toolkit every AI app is built from.
- 11HTTP clients with httpxhttpx for Java and JavaScript developers: GET and POST, JSON bodies, query params and auth, Client and AsyncClient with connection pooling, status codes, timeouts, retries that honour Retry-After, streaming an LLM reply line by line, and testing with MockTransport.
- 12FastAPIFastAPI for Java and JavaScript developers: routes, path and query parameters, Pydantic bodies and automatic 422 errors, response models, HTTPException, Depends, async endpoints, lifespan with one shared HTTP client, SSE streaming, background tasks, CORS, /docs and TestClient.
- 13Testing with pytestpytest for Java and JavaScript developers: plain assert, running and picking tests, fixtures with setup and teardown, parametrize, tmp_path and monkeypatch, unittest.mock, and testing LLM code without a model: fake clients, httpx.MockTransport, prompt snapshots, live tests and async tests.
- 14Project structure and loggingLay out a real AI service like a Spring or Node developer would expect: src layout, packages, imports and circular imports, pyproject.toml in depth, ruff and pre-commit, then logging done properly: a logger per module, JSON logs with request ids, and LLM calls logged without secrets or PII.
- 15NumPy for AINumPy for Java and JavaScript developers: arrays, dtype and shape, slicing and masks, vectorised maths, broadcasting, @ and axis, then the AI part: cosine similarity between embeddings, top-k search with argsort, seeded randomness, and float32 vs float64.
- 16pandas for AIpandas for Java and JavaScript developers: Series and DataFrames, reading CSV and JSONL, loc and iloc, filters, missing data, cleaning text with .str, groupby, merge, pivot tables, and why vectorised code beats apply. You finish by building an eval report from LLM results.
- 17Working with text and documentsTurn messy files into clean chunks for RAG: bytes and encodings, Unicode cleanup, regex extraction, splitting sentences, parsing Markdown by headings, HTML with BeautifulSoup and PDFs with pypdf, then token counting with tiktoken, chunking with overlap and metadata, and removing duplicates.
- 18Performance: threads, processes and asyncMake Python AI code fast, explained for Java and JavaScript developers: the GIL, I/O-bound vs CPU-bound work, thread pools, process pools, asyncio for many LLM calls, a decision table, batching, caching LLM replies, profiling with cProfile, and NumPy before parallelism.
Part C · Core ML and PyTorch
The machine learning basics AI engineer interviews still ask, with just enough PyTorch.
- 19How machine learning worksMachine learning for Java and JavaScript developers: a model is a function with learned parameters. Features and labels, loss, gradient descent by hand in NumPy, learning rate, scikit-learn, train/validation/test splits, and how LLMs learn from next-token prediction.
- 20Classic models with scikit-learnscikit-learn for Java and JavaScript developers: the fit/predict API, linear and logistic regression, decision trees, random forests, k-NN, StandardScaler, Pipeline, train_test_split, a TF-IDF ticket router, and when a classic model beats an LLM on cost, speed and data.
- 21Metrics: precision, recall, F1 and AUCClassification metrics for Java and JavaScript developers: the confusion matrix, why accuracy lies on imbalanced data, precision, recall, F1, choosing a threshold, ROC AUC and PR AUC, by hand in NumPy and with sklearn.metrics, plus MAE, RMSE, recall@k and LLM-judge agreement.
- 22Overfitting and data leakageOverfitting and data leakage for Java and JavaScript developers: underfitting vs overfitting, bias and variance, Ridge and max_depth, k-fold cross-validation, the leaks that fake a great score (and the Pipeline fix), and eval sets leaking into LLM prompts and fine-tuning data.
- 23PyTorch basicsPyTorch for Java and JavaScript developers: install it with uv, create tensors and read their shape, dtype and device, move data to and from NumPy, broadcast and multiply matrices, reshape and index, let autograd compute gradients, and run on cuda or Apple mps.
- 24Your first neural networkBuild and train a small neural network in PyTorch, step by step: nn.Module and nn.Linear, ReLU, logits and softmax, CrossEntropyLoss, the Adam optimizer, the five-line training loop, DataLoader batches, eval mode and no_grad, validation accuracy, seeds, and saving a state_dict.
- 25Embeddings and attention in codeAttention for Java and JavaScript developers, line by line: token ids to embeddings, scaled dot-product attention by hand in NumPy with numbers you can follow, the causal mask, positions, multi-head attention, the same in PyTorch checked against F.scaled_dot_product_attention, a transformer block and the KV cache.
- 26Pretrained models and fine-tuningUse pretrained models from Python: Hugging Face pipeline(), AutoTokenizer and AutoModel, embeddings with sentence-transformers next to Ollama, model cards and licences, when to fine-tune instead of prompting or RAG, and LoRA explained in NumPy, then trained with peft on a CPU.
Then build
Put the Python to work in the Build labs: call a model, stream answers, tool calling and RAG, step by step.