▶ Sign up free for the video, slides & prompts
The lesson below is open to all. Enter your email once to unlock every video, slide deck, prompt and code example on this device.
Checking…
Mini project: command-line study buddy
A chatbot that quizzes you on any topic.
🎬 Video version coming soon — read it now
Let's build an AI study buddy that quizzes you on any topic: it asks questions, checks your answers, explains mistakes and keeps score. It uses everything from this course.
The plan
- Ask the user for a topic
- Get 5 quiz questions from the model as structured output
- Ask each question, collect the answer
- Have the model mark each answer, again as structured output
- Show a score and save the session to JSON
The code
What to notice
- Two AI roles: one call writes questions, another marks answers. Each has its own focused system prompt.
- Structured output everywhere: the program never parses free text.
- score += result.correct works because True counts as 1 and False as 0.
- Graceful failure: an API problem gives a friendly message instead of a crash.
- The model marks by meaning, which normal code can't do: "a list keeps order" and "lists are ordered" both count.
Challenges
- Let the user choose the number of questions and a difficulty level.
- At the end, ask the model for a 3-line study plan based on the wrong answers.
- Keep a
progress.jsonacross sessions and show improvement per topic. - Write 5 test answers (right, wrong, and right-but-misspelled) and check the marking is fair.
Remember
The model can mark a correct answer wrong, or the reverse. That's fine for practice, but tell users it's an AI marker, and never use it alone for marks that matter.
In one line
You built an AI quiz app with two structured AI calls, error handling and saved sessions, which is a real AI product in miniature.
Share with a friend