Command Palette

Search for a command to run...

Hectal
Phase 17Advanced18 of 18 in Python

Interviews and Capstone

Answer the Python questions interviewers really ask, with a runnable proof for each, then build and ship a complete document question-answering tool.

The first half of this phase is interview preparation done properly. Each topic takes a family of questions (core language, "what does this print?", object model and internals, coding rounds, production Python) and gives the precise answer, the reason behind it, and a program you can run to see it happen. An interviewer rarely wants a definition. They want to hear that you know why.

The second half is a capstone: a document question-answering tool called docqa. You plan it, build the core library (loading, chunking, a toy embedder, NumPy search, a model interface with a fake and a real client), add a command line with config, logging, streaming and retries, then test, package and ship it. Every piece uses ideas from earlier phases, so this is also the best way to find what you still need to revisit.

The phase ends with an honest map of where to go next: what an AI engineer, a forward deployed engineer and an AI scientist do day to day, which skills from this course each role leans on, and what to learn after it.

0/10 · 0%
10 topics ~5 h 27 code blocks & diagrams
Start with the first topic
1
17.1

Interview Deep Dive: Core Language Questions

The core-language questions that come up in almost every Python interview: mutability, is versus ==, default arguments, scope, copying, comprehensions and truthiness. For each one you get the precise answer and a program that proves it.

30 min 1 diagram 2 code practice

2
17.2

Interview Deep Dive: What Does This Print?

The famous Python puzzles (late-binding closures, class versus instance attributes, tuples holding lists, exhausted generators, integer caching, dict ordering) explained by the rule behind each, so you can predict the output instead of memorising it.

29 min 2 code practice

3
17.3

Interview Deep Dive: OOP and Internals

How Python's object model really works, the way senior interviews probe it: method resolution order, descriptors, __new__ versus __init__, the GIL, garbage collection, decorators, generators versus iterators, __slots__ and context managers.

30 min 3 code practice

4
17.4

Interview Deep Dive: Coding Rounds in Python

The Python idioms that save minutes in a coding round: Counter, defaultdict, heapq, bisect, deque, slicing, sorted with key, and itertools, plus the time complexity of every built-in you will lean on and how to talk through a solution.

30 min 4 code practice

5
17.5

Interview Deep Dive: Python in Production

The questions that separate someone who has written scripts from someone who has run Python services: packaging and environments, async versus threads versus processes, finding memory and speed problems, testing strategy, typing, and API design.

30 min 2 code practice

6
17.6

Capstone: Plan a Document Question-Answering Tool

Before writing code, decide what the tool must do and how its parts fit. You will plan docqa, a tool that answers questions about a folder of text documents, with requirements, an architecture, typed data classes and interfaces, and a project layout.

27 min 2 code practice

7
17.7

Capstone: Build the Core Library

Build the heart of docqa: a chunker with overlap, a toy embedder, NumPy top-k retrieval, a prompt builder with numbered sources, a ModelClient interface with a scripted fake and a real client, all typed and easy to test.

33 min 1 diagram 2 code practice

8
17.8

Capstone: CLI, Config, Logging and Streaming

Turn the core library into a real command-line tool: argparse arguments, configuration from the environment with secrets handled safely, logging that helps you debug, clean error handling, streamed output, and retries with backoff.

30 min 3 code practice

9
17.9

Capstone: Test, Package and Ship It

Finish docqa like a professional project: a test suite built on fakes, Ruff and a type checker, a pyproject.toml with a console command and a lock file, a Dockerfile, a README, and a list of what to build next.

29 min 3 code practice

10
17.10

Where to Go Next: AI Engineer, Forward Deployed Engineer, AI Scientist

What three AI-era roles do day to day, which skills from this course each one uses most, and what to learn after it, with the Hectal courses that already exist and the ones that are planned.

26 min 2 code practice

Practise this phase

Hands-on exercises: write the code, run it, and press Check to have it tested automatically.

1

Fix the list that remembers too much

The function add_tag(tag, tags=[]) appends tag to a list and returns the list. A call that does not pass tags should start from a new, empty list, but today every such call shares one list. (See Topic 17.1.)

Intermediate
2

Top k frequent words

Write top_words(text, k) that lowercases text, splits it on whitespace, and returns a list of the k most frequent words. Higher counts come first. Words with equal counts are ordered alphabetically.

Intermediate
3

Flatten nested lists

Write flatten(data) that takes a list that may contain other lists or tuples (to any depth) and returns one flat list in the original order.

Intermediate
4

Build an LRU cache

Write a class LRUCache(capacity) (least recently used). get(key) returns the value, or -1 if the key is missing, and marks the key as recently used. put(key, value) stores a value and marks it recently used; if the cache is over capacity afterwards, it removes the least recently used key.

Advanced
5

Capstone piece: a chunker with overlap

Write chunk_text(text, size, overlap) that splits text into chunks of up to size words, where each chunk starts size - overlap words after the previous one. Return a list of strings (words joined by one space).

Advanced
6

Capstone piece: top-k retrieval with scores

Write top_k(query, matrix, k). query is a list of numbers, matrix is a list of rows (each the same length). Compute the cosine similarity of the query with every row (the dot product divided by the product of the two lengths; Topic 16.8) and return the best k as a list of (row_index, score) tuples, highest score first, scores rounded to 3 decimals.

Advanced