Python and AI.

A Hack Your Future lesson: build what’s next. Clean a dataset with Python, then talk to an AI agent running on your own computer.

The whole lesson in under four minutes. Captions are on the picture and music is built in. Press the speaker button for sound. Also available: the dark version for projecting and subtitle files for the light and dark videos.

The whole lesson in a few commands

# 1. Make an isolated environment
python3 -m venv .venv && source .venv/bin/activate
# 2. Install the library, then download a model
pip install ollama
ollama pull olmo-3:7b-instruct
# 3. Clean and summarize the data
python wrangle.py
# 4. Ask a local agent about it
python local_agent.py "Which branch had the most loans?"

You need Python 3.9 or newer and Ollama. The scripts and data are in the scripts folder, or download them as a zip. Everything runs on your own machine.

Welcome. Let’s make Python work with AI.

Python is the language most people reach for when they work with data and AI. It reads almost like plain English, it has libraries for nearly everything, and it can steer a model running on your own computer. In this lesson you’ll clean a messy dataset with a short script, then build a small agent: a local model that answers questions about the data by calling Python functions.

You can watch the walkthrough, follow the slides, step through the lab, or jump straight to the scripts and run them. We use a made-up dataset so there is nothing private to protect, and the agent only gets narrow, read-only tools.

Make a prediction. Before the demo you’ll be asked: when an agent “calls a tool”, who actually runs the code, the model or your script? Write your answer down. We’ll check it in the lab.

Follow the session in order.

Learn the ideas, explore the lab, then run the scripts yourself.

Slides

Two decks of four slides. Light is for printing and dark is for projecting.

For instructors

Talking points, answer keys and citations, and flash cards that print double-sided.

The scripts

Runnable Python that does for real what the lab shows. Read the README in the scripts folder first.

  • wrangle.pyClean and summarize the dataOpen
  • wrangle_pandas.pyThe same job with pandasOpen
  • hello_local.pyCall a local modelOpen
  • local_agent.pyA small, safe agentOpen
  • make_data.pyMake the sample dataOpen
  • loans.csvThe sample dataOpen
  • All of the scriptsOne ZIP with the scripts, sample data and READMEZIP

What you will learn.

Small scripts, run on your own machine, that you can read in full.

Why Python for AI

Readable code, a huge ecosystem, and fast compiled libraries underneath: why Python became the glue.

Clean and summarize data

Load a CSV, fix names and numbers, remove duplicates, and group and sort, with the standard library or pandas.

Build a safe local agent

A model, some tools and a loop, with read-only tools, checked arguments, a step limit and a log.