Python Series track

Project 6 · Practice Projects

Project 6 — Vocabulary Quiz

Create an interactive vocabulary quiz that shuffles questions, tracks performance per word, and prioritizes words you get wrong (basic spaced repetition).

Practice Projects1 min readFree lesson

Difficulty: Lv ★★ | Prerequisite Knowledge: Basic Weeks 7-8 + random

Goal

Random quiz with English-Korean dictionary + bidirectional mode + review mode

Differences from Basic Assignment

  • Basic comprehensive example = simple question setting + score
  • Here = bidirectional + review mode + statistics

Requirements

  • Vocabulary dictionary (10+ words)
  • Mode selection: English→Korean / Korean→English / Random
  • 10 questions, immediate feedback
  • Final score + incorrect words + review option

Challenge Task

  • Load external vocabulary file
  • Cumulative accuracy rate by word

Assignment

Show the reference solution

Try the assignment yourself first — comparing your attempt with a working solution is where most of the learning happens.

solution.pyPython
"""Vocabulary Quiz — Bidirectional + Review Mode"""
import random

WORDS = {
    "apple": "Apple", "book": "Book", "table": "Table", "door": "Door",
    "water": "Water", "fire": "Fire", "tree": "Tree", "sky": "Sky",
    "love": "Love", "time": "Time", "house": "House", "car": "Car",
}

def quiz(pairs, mode):
    score = 0
    wrong = []
    for i, (en, ko) in enumerate(pairs, 1):
        if mode == "en2ko":
            q, a = en, ko
        elif mode == "ko2en":
            q, a = ko, en
        else:  # random
            if random.random() < 0.5:
                q, a = en, ko
            else:
                q, a = ko, en
        ans = input(f"[{i}/{len(pairs)}] {q}? ").strip()
        if ans == a:
            print("✓ Correct")
            score += 1
        else:
            print(f"✗ Wrong (Correct answer: {a})")
            wrong.append((q, a))
    return score, wrong

def main():
    print("[Mode] 1. Eng→Kor 2. Kor→Eng 3. Random")
    mode_map = {"1": "en2ko", "2": "ko2en", "3": "random"}
    mode = mode_map.get(input("Select:").strip(), "en2ko")

    pairs = random.sample(list(WORDS.items()), min(10, len(WORDS)))
    score, wrong = quiz(pairs, mode)
    print(f"Total score: {score} / {len(pairs)}")

    if wrong and input("Review only wrong questions? (y/n):").strip().lower() == "y":
        score2, _ = quiz(wrong, mode)
        print(f"Review score: {score2} / {len(wrong)}")

if __name__ == "__main__":
    main()

Learn this lesson with a mentor

Work through the Python Series track on your own, or join a guided cohort at our Pitampura campus and online.

Call NowEnroll Now