A quiz app needs questions, answer choices, a loop, input validation, and score tracking. Represent each question as a dictionary so the data remains separate from the program logic.
questions = [
{"text": "Which keyword defines a function?", "answer": "def"},
{"text": "What type stores key-value pairs?", "answer": "dict"},
]
score = 0
for question in questions:
answer = input(question["text"] + " ").strip().lower()
if answer == question["answer"]:
score += 1
print("Correct")
else:
print(f"Not quite. Answer: {question['answer']}")
print(f"Score: {score}/{len(questions)}")Improve it by adding multiple-choice options, randomized order, categories, difficulty levels, a timer, and a results file. Validate answers instead of assuming the user enters the exact expected format. For a larger project, create Question, Quiz, and Result classes or use small functions with clear responsibilities.
Do not store passwords or personal information in a beginner quiz app. If you publish scores, add authentication and privacy controls. The project is valuable because it teaches data modeling and control flow – not because it needs dozens of features.