Python for AI from Zero: First Program to First LLM Call
BeginnerNo experience needed: build a flashcard quiz on your notes that explains what you missed.
You build
A command-line study assistant that quizzes you on flashcards from your own notes files, keeps your best scores in a file, and asks a language model to explain the cards you missed.
You need
Nothing. This course starts from zero.
To build it on your own machine
This is optional and comes with a plan. The course pack brings the starting files, a ready container and a check for every lesson. You need only Docker and git, plus your own AI coding agent if you want a tutor.
What you learn
Start with one line of code and end with a program that asks a language model
You have never written code and you want to build with AI. You write one program from the first lesson to the last: a study assistant for the terminal. It starts as one line that prints a greeting. Then it quizzes you on flashcards from your own notes files, reviews the cards you missed, keeps your best scores, and at the end asks a language model to explain what you got wrong. Each lesson adds one small part that runs, and you finish ready for the courses that start from Python basics.
- Python from the First Line. What a program is and how to run one, then values, variables, text, decisions and loops. Each idea arrives when the program needs it.
- Data a Program Can Keep. Lists and dictionaries hold the data while the program runs, text files and JSON keep it between runs, and errors are read and handled so a small mistake ends in a clear message.
- Code in Good Shape. Functions give each job a name, modules give each group of functions its own file, an installed package adds what Python does not ship, a first test proves a function does what it should, and a class of your own joins data with the code that works on it.
- A First Call to a Language Model. Settings and a secret key kept outside the code, one request to a web API written by hand to see what travels over the wire, then the same request through the client package that most AI code in Python uses.
Lessons
Write and Run Your First Program
Programs and Python, The terminal, Running a Python file, print and text
Values and Variables
Values and types, Variables, Arithmetic, f-strings
Read an Answer and Compare It
Reading input, String methods, Comparisons and booleans
Make Decisions with if, elif and else
if and else, Indented blocks, elif chains, Combining conditions
Try Again with a while Loop
while loops, Counters, break, Loops that never end
Many Cards: Lists and for Loops
Lists, Indexes, for loops, Splitting text
Collect the Cards You Missed
Lists that grow, Collecting in a loop, len and empty lists
Give Each Job a Name with Functions
Defining and calling, Parameters and arguments, Return values, Local variables
Dictionaries: Records with Named Parts
Dictionaries, Reading and changing entries, Lists of dictionaries
Read Cards from a Notes File
Modules and import, Paths, Reading a text file, Lines of text
Choose a Subject and Handle Errors
Command-line arguments, Reading a traceback, Exceptions, try and except
Keep Your Best Scores in a JSON File
Writing a text file, JSON, Saving and loading data, The first run
Split the Program into Modules
Your own modules, What import runs, One job per module, Type hints
Install pytest and Write a First Test
Third-party packages, Project dependencies, Test functions, Reading a failed test
A Class of Your Own: the Flashcard
Classes and objects, __init__ and attributes, Methods and self, Every value is an object
Settings and Secrets in a .env File
Environment variables, .env files, Secrets stay out of the code, A config module
Call a Web API by Hand
Web APIs, HTTP requests and responses, JSON in and out, API keys
Explain Missed Cards with a Language Model
The OpenAI-compatible client, Messages and roles, Prompts built from data, When the call fails
Where it fits
Course 1 of 8 on the AI Engineer path.