Learning guide

Python for AI: what to learn first, in order, with practice ideas

The Python you actually need for AI engineering: basics, data structures, files and JSON, NumPy and pandas, calling APIs, async and testing, in a sensible order.

2 min readFree, no sign-up

Short answer: for AI engineering you need solid everyday Python, not advanced tricks. Learn the core language, then data handling (JSON, NumPy, pandas), then calling web APIs, then testing and clean structure. After that, the AI libraries make sense, because they are mostly ordinary Python that moves data around.

The order that works

  1. Core language: variables, strings, lists, dictionaries, loops, functions, and reading error messages.
  2. Structure: modules, classes (simple ones), virtual environments and installing packages.
  3. Files and JSON: reading and writing text, CSV and JSON. Model APIs speak JSON, so this is used daily.
  4. NumPy and pandas: arrays, vector operations, filtering and grouping tables. Embeddings and metrics are arrays.
  5. HTTP and APIs: calling a service with requests or an SDK, handling errors, retries and timeouts.
  6. Testing and typing: pytest, type hints and dataclasses (or Pydantic) so you can validate model output.
  7. Async basics: async and await, useful when calling many APIs at once.

One small program that uses most of it

import json

data = json.loads('{"items": [{"name": "a", "score": 0.8}, {"name": "b", "score": 0.4}]}')
good = [i["name"] for i in data["items"] if i["score"] >= 0.5]
print(good)

It prints ['a']: parse JSON, filter with a list comprehension, print the result. Replace the string with a real API response and you have the shape of many AI scripts.

What to skip at first

Metaclasses, decorators written from scratch, packaging for PyPI and low-level performance tuning. Come back when a project needs them.

How to practise

  • Write a script that reads a CSV, cleans it and prints three statistics.
  • Call a public API, save the JSON and summarise it.
  • Write five tests for a function that cleans text.
  • Then move on to embeddings and a small RAG app.

Where this fits in a full plan

Python is the first block of the AI engineer roadmap. If you are starting from school, read how to become an AI engineer after 12th. Our free lessons let you run Python in the browser with no installation.