Skip to content

Flashcard study app

Zee Hey, so. I've got the propulsion systems exam in six weeks and I learn way better by testing myself. Can you build a flashcard app? Loads cards from a file, shows me the front, I type my answer, it tells me if I got it right. And I want it to save my progress so I can pick up where I left off. Please 🙏

What you're building

Deck: python-basics.json (12 cards)

Front: What does len() return for a string?
Your answer: the number of characters
Correct!

Front: What type does input() always return?
Your answer: int
Incorrect. The answer is: str

---
Session complete: 8/12 correct.
Progress saved.

What you'll need

Hints

Start with the data, not the classes. A card is two strings: front and back. A deck is a list of cards. Get that working first, then wrap it in classes if you want the cleaner interface.

JSON handles the file format. json.load() reads a file into a Python list or dictionary. json.dump() writes it back. The json module is in the standard library.

Wrap the file load in try/except. The first time the script runs, the save file won't exist. Catching FileNotFoundError lets you start with an empty deck gracefully instead of crashing.

Going further

Once the core study loop works:

  • Repeat wrong answers. Keep track of which cards the player got wrong and loop through them again at the end of the session.
  • Multiple decks. List the available .json files in a folder and let the user choose which deck to study.
  • Spaced repetition. Record how many times each card was answered correctly. Show cards answered correctly less often more frequently.