How much Python do you need for AI engineering? A tiered answer
In this article (7 sections)
Related programme: the Generative & Agentic AI course (3 months).
For AI engineering — building applications on top of language models — you need solid everyday Python rather than advanced tricks: functions and data structures, reading and writing JSON and files, calling HTTP APIs with error handling, type hints, virtual environments, testing with pytest, and enough asynchronous code to make concurrent API calls. Deep knowledge of metaclasses or CPython internals can wait. What separates hireable from not is usually error handling and testing, not syntax.
Tier 1: essential from day one
You will use these in almost every task.
| Skill | Why AI work needs it |
|---|---|
| Functions, dicts, lists, comprehensions | Shaping prompts, parsing responses, preparing data |
| Strings and f-strings | Building prompts and templates safely |
json module | Model APIs speak JSON; tool calls arrive as JSON |
Files and paths (pathlib) | Reading documents, saving outputs and test sets |
Exceptions (try/except) | Model and API calls fail; your code must not |
Virtual environments and pip | Reproducible projects that others can run |
| Reading a traceback | Most debugging starts here |
Tier 2: needed for production work
These are what most interview take-home tasks and code reviews check.
| Skill | Why |
|---|---|
| Type hints and dataclasses or Pydantic models | Validating structured model output against a schema |
| HTTP clients, timeouts and retries with backoff | Rate limits and transient errors are normal |
asyncio basics | Running many model calls concurrently within limits |
pytest | Testing parsing, validation and tool functions |
Logging (logging module) | Tracing what happened in a request |
| Environment variables for configuration | Keeping keys and settings out of code |
| Packaging a small project | So a colleague can install and run it |
| pandas basics | Evaluation results, test sets and reports |
Tier 3: can wait
Useful later, rarely the blocker for an entry or mid-level AI engineering role:
- metaclasses, descriptors and advanced decorators beyond the basics,
- C extensions and performance tuning of Python itself,
- writing your own async framework,
- deep NumPy broadcasting tricks (unless you work on model training).
Learn them when a real problem needs them.
A five-minute self-test
Read this function and predict the output before running it. It parses a model's structured output — a very common AI-engineering task — and it contains the Tier 1 and 2 ideas in miniature.
import json
from dataclasses import dataclass
@dataclass
class Invoice:
number: str
total: float
def parse_invoice(raw: str) -> Invoice | None:
"""Return an Invoice, or None if the model output is unusable."""
try:
data = json.loads(raw)
except json.JSONDecodeError:
return None
if not isinstance(data, dict):
return None
number, total = data.get("number"), data.get("total")
if not isinstance(number, str) or not number.strip():
return None
try:
total = float(total)
except (TypeError, ValueError):
return None
if total < 0:
return None
return Invoice(number.strip(), round(total, 2))
cases = [
'{"number": "INV-104", "total": "18450.50"}', # total as string
'{"number": "INV-105", "total": -20}', # negative
'Sure! Here is the JSON: {"number": "INV-106"}',# prose around JSON
'["INV-107", 900]', # wrong shape
'{"number": " INV-108 ", "total": 999.999}', # whitespace, rounding
]
results = [parse_invoice(c) for c in cases]
for c, r in zip(cases, results):
print(r)
assert results[0] == Invoice("INV-104", 18450.5)
assert results[1] is None and results[2] is None and results[3] is None
assert results[4] == Invoice("INV-108", 1000.0)If you predicted all five correctly, and you could explain why case 3 fails and how you might handle it (for example, by asking the model for strict JSON output, or extracting the JSON object before parsing), your Tier 1 is solid. If you would also write tests for these cases and log the rejected ones, you are working at Tier 2.
What interviewers check
In AI engineering take-home tasks and live coding, reviewers commonly look for:
- 1Handling bad model output without crashing, as above.
- 2Timeouts and retries around API calls, with a limit.
- 3Secrets out of code.
- 4Tests for the parts that are deterministic.
- 5Readable structure — small functions with clear names.
Clever one-liners rarely help; clear, defensive code does.
A learning order that works
If you are starting from basic Python:
- 1Weeks 1–2: Tier 1, using small scripts that read files and JSON.
- 2Weeks 3–4: call a model API; add error handling, timeouts and logging.
- 3Weeks 5–6: dataclasses or Pydantic for output validation; write pytest tests.
- 4Weeks 7–8: asyncio for concurrent calls with a concurrency limit; package the project.
By the end you have one project that demonstrates every Tier 2 skill, which is better evidence than several tutorials.
Is TypeScript needed too?
Some AI engineering roles, especially those building web products or agent tool servers, also use TypeScript. See TypeScript for AI engineers to judge whether it matters for your target roles.
The Generative & Agentic AI add-on assumes working Python and builds Tier 2 habits through its projects. If you are coming from data science, what to relearn when moving to AI engineering explains which of your habits to keep.
Frequently asked questions
Do I need to know machine learning maths to be an AI engineer?
For building applications on existing models, you need less maths than for training models, but you still need statistics for evaluation — proportions, sampling and how much a result can vary. Roles that train or fine-tune models need more.
Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.
This article is part of our Generative & Agentic AI programme — 3 months. Add practical GenAI, retrieval and agent-building skills to your existing toolkit.
Explore Generative & Agentic AI