Optional beginner bridge · 45–60 minutes

Python you need for this course.

You do not need to become a Python developer before learning RAG. This bridge covers only the patterns used repeatedly in the labs.

Start here

Check Python first.

python3 --version
python3 - <<'PY'
print("Python bridge ready")
PY

If this works, continue. Copy examples into a temporary folder; nothing here needs a cloud account.

1. Values, variables and print

question = "Which port does the API use?"
port = 8080
print(question)
print(port)

Variables let us give names to inputs, configuration and evidence.

Try: change one value, rerun it, and predict the output before pressing Enter.

2. Lists and dictionaries

sources = ["network.md", "access.md"]
record = {"source_id": "network.md", "status": "active"}
print(sources[0])
print(record["source_id"])

RAG pipelines constantly move lists of records and metadata dictionaries.

Try: change one value, rerun it, and predict the output before pressing Enter.

3. Loops and conditions

for source in sources:
    if source.endswith(".md"):
        print("index", source)

Loops process corpora; conditions implement deterministic policy and filtering.

Try: change one value, rerun it, and predict the output before pressing Enter.

4. Functions

def retrieve(query, records):
    return [r for r in records if query.lower() in r["text"].lower()]

Functions help us separate ingestion, retrieval, context construction and generation.

Try: change one value, rerun it, and predict the output before pressing Enter.

5. Files

from pathlib import Path
text = Path("network.md").read_text()
print(text)

The first labs use local files so every source is inspectable.

Try: change one value, rerun it, and predict the output before pressing Enter.

6. JSON

import json
record = {"source_id":"network.md", "text":"API uses 8080"}
print(json.dumps(record, indent=2))

JSON is a common shape for APIs, metadata records, traces and evaluation results.

Try: change one value, rerun it, and predict the output before pressing Enter.

7. HTTP with the standard library

from urllib.request import urlopen
# Example only: call a local service you control
with urlopen("http://127.0.0.1:8000/health") as r:
    print(r.status)

Later systems expose retrieval/generation services over HTTP; core labs remain account-free.

Try: change one value, rerun it, and predict the output before pressing Enter.

8. Virtual environments

python3 -m venv .venv
. .venv/bin/activate
python -m pip --version

A virtual environment isolates optional packages from your system Python.

Try: change one value, rerun it, and predict the output before pressing Enter.

Ready check

You are ready for Module 01 if you can:

  • run a Python file or heredoc from the terminal;
  • read a list and dictionary;
  • understand a small function and loop;
  • read/write a local text file;
  • recognize JSON-shaped data.