
This beginner-friendly Python project is a fun way to test your general knowledge with a simple multiple-choice quiz game. The program asks a series of questions, lets you choose your answers, and gives you instant feedback along with your final score.
All the questions are neatly organized in a dictionary, so it’s super easy to add more or even create different quiz categories. Itβs a great little project to help you practice key programming concepts like loops, conditionals, functions, and working with user input.
Whether you’re just starting out with Python or looking for a fun side project, this quiz game is a great way to build your skills while having a bit of fun!
π‘ Features:
User-friendly interface with emojis and clean formatting.
Robust input validation.
Feedback after each question (correct/incorrect).
Personalized greeting and score summary.
Modular and readable structure with well-named functions.
import time
# -----------------------------
# Quiz data
# -----------------------------
quiz_questions = [
{
"question": "What is the capital of France?",
"options": ["A) Paris", "B) London", "C) Rome", "D) Berlin"],
"answer": "A"
},
{
"question": "Which planet is known as the Red Planet?",
"options": ["A) Earth", "B) Mars", "C) Venus", "D) Jupiter"],
"answer": "B"
},
{
"question": "Who wrote 'Hamlet'?",
"options": ["A) Charles Dickens", "B) William Wordsworth", "C) William Shakespeare", "D) Jane Austen"],
"answer": "C"
},
{
"question": "Which language is primarily used for web development?",
"options": ["A) Python", "B) Java", "C) HTML", "D) C++"],
"answer": "C"
},
{
"question": "What is the boiling point of water?",
"options": ["A) 100Β°C", "B) 90Β°C", "C) 120Β°C", "D) 80Β°C"],
"answer": "A"
}
]
# -----------------------------
# Utility Functions
# -----------------------------
def welcome_user():
print("π Welcome to the Simple Quiz Game! π")
name = input("Enter your name: ")
print(f"\nHello, {name}! Let's test your knowledge.\n")
time.sleep(1)
return name
def ask_question(q, index):
print(f"Question {index + 1}: {q['question']}")
for option in q["options"]:
print(option)
answer = input("Your answer (A/B/C/D): ").strip().upper()
while answer not in ['A', 'B', 'C', 'D']:
answer = input("Please enter a valid option (A/B/C/D): ").strip().upper()
return answer == q["answer"]
def show_results(score, total):
print("\nπ Quiz Completed! π")
print(f"Your Score: {score} out of {total}")
percentage = (score / total) * 100
if percentage == 100:
print("π Perfect! You're a quiz master!")
elif percentage >= 70:
print("π Great job! You really know your stuff.")
elif percentage >= 50:
print("π Not bad, but you can do better.")
else:
print("π
Keep practicing, you'll get there!")
# -----------------------------
# Execution Program
# -----------------------------
def run_quiz():
user_name = welcome_user()
score = 0
total_questions = len(quiz_questions)
for i, question in enumerate(quiz_questions):
print("-" * 50)
if ask_question(question, i):
print("β
Correct!\n")
score += 1
else:
print(f"β Wrong! The correct answer was {question['answer']}.\n")
time.sleep(1)
print("-" * 50)
show_results(score, total_questions)
print("\nThank you for playing, " + user_name + "! π")
# Entry
if __name__ == "__main__":
run_quiz()