Day 93 of 100 Days Coding Challenge: Python
Ninety-three days into this Python marathon, it suddenly hit me: I’ve only got a week left. The thought made me a little sad—like reaching the last few pages of a great book and realizing the ending is near. But rather than mope, I decided to channel that energy into something fun.
Today’s feature: quizzes. That’s right, the Civilization Timeline Builder is now handing out pop quizzes like a history teacher who drank too much coffee. The quiz pulls from the same filters (year range, regions, tags) you’ve already selected and generates random questions. “Which came first?” “Match the civ to the years?” It’s like turning my carefully curated data into a trivia night—minus the nachos, unfortunately. When you finish, the program even returns your score. History with instant feedback—cool, right?
Today’s Motivation / Challenge
Why does this matter? Because learning sticks better when you test yourself. You can scroll through timelines all day, but nothing sharpens your memory like a question asking, “Did the Gupta Empire adopt iron later than Rome?” Quizzes make history interactive, playful, and just a little competitive—especially if you’re the type who hates losing, even to yourself.
Purpose of the Code (Object)
The code auto-generates quiz questions based on your current filters. It randomizes both the content and the order, then provides a scoring system when you submit. There’s even a “show answers” toggle, so you can learn from your mistakes without a stern lecture.
AI Prompt
Please add the following function:
Quiz mode
- Auto-generate 10 questions (“Which came first?”, “Match civ→years”).
- Accept: scoring & “show answers” toggle.
Functions & Features
- Generate random quiz questions from filtered civilizations and events.
- Support multiple-choice or “which came first” style questions.
- Return a score when the quiz is submitted.
- Provide reset and show-answer options for replay and review.
Requirements / Setup
You’ll need:
- Python 3.11
Installs:
pip install streamlit
Minimal Code Sample
import random
questions = random.sample(filtered_events, 10)
for q in questions:
st.write(f”Which came first: {q[0].name} or {q[1].name}?”)
Picks 10 random event pairs and asks the user to guess which happened earlier.
The Civilization Timeline Builder
Notes / Lessons Learned
As long as I followed the instructions, it was surprisingly straightforward. Since it shares the same sidebar filters, I had to insert the quiz logic right after the filter selections.
To keep things flexible, I used st.number_input to let users decide how many questions they want. With the random library already installed, the program pulls events at random and builds the quiz. I even added two buttons: one to submit answers and another to reset the quiz entirely, giving users the choice to try again.
What struck me is how reusable this structure is. Today it’s history trivia, but tomorrow it could just as easily be a vocabulary quiz, a math drill, or even a fun little self-test on Python syntax. Who knew that adding a quiz mode could make history—and coding—feel a lot like game night?
Optional Ideas for Expansion
- Add a timer for extra pressure (and bragging rights).
- Track high scores across sessions.
Let users choose the quiz type: matching, multiple-choice, or true/false.

