The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

Build a vocabulary quiz generator

Here’s a straightforward Python script for a vocabulary quiz generator. It randomly picks words from a dictionary and quizzes the user on their meanings. You can easily extend it with your own word list or integrate it into a larger application.

python
import random # Sample vocabulary dictionary: word -> meaning vocab = { "ubiquitous": "present, appearing, or found everywhere", "ephemeral": "lasting for a very short time", "loquacious": "tending to talk a great deal; talkative", "enigma": "a person or thing that is mysterious or difficult to understand", "gregarious": "fond of company; sociable", "obfuscate": "to make something obscure or unclear", "cacophony": "a harsh, discordant mixture of sounds", "deleterious": "causing harm or damage", "pulchritude": "beauty", "quixotic": "exceedingly idealistic; unrealistic and impractical", } def generate_quiz(vocab, num_questions=5): words = list(vocab.keys()) questions = random.sample(words, min(num_questions, len(words))) score = 0 for i, word in enumerate(questions, 1): print(f"Question {i}: What is the meaning of '{word}'?") answer = input("Your answer: ").strip().lower() correct_meaning = vocab[word].lower() if answer in correct_meaning or correct_meaning in answer: print("Correct!n") score += 1 else: print(f"Incorrect! The correct meaning is: {vocab[word]}n") print(f"Quiz complete! Your score: {score} out of {len(questions)}") if __name__ == "__main__": print("Welcome to the Vocabulary Quiz!n") generate_quiz(vocab, num_questions=5)

This quiz asks for a free-text answer and checks if your input appears in the meaning. For more accuracy, you could add multiple-choice or more sophisticated answer checking.

Want me to build a version with multiple-choice questions or exportable quizzes?

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About