-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimplequizz.py
More file actions
65 lines (58 loc) · 1.5 KB
/
Copy pathSimplequizz.py
File metadata and controls
65 lines (58 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Simple Quiz App (Improved)
questions = [
{
"question": "What is the capital of France?",
"options": {
"A": "Paris",
"B": "London",
"C": "Berlin",
"D": "Madrid"
},
"answer": "A"
},
{
"question": "What is 5 + 7?",
"options": {
"A": "10",
"B": "11",
"C": "12",
"D": "13"
},
"answer": "C"
},
{
"question": "Who wrote 'Romeo and Juliet'?",
"options": {
"A": "Charles Dickens",
"B": "William Shakespeare",
"C": "Mark Twain",
"D": "Jane Austen"
},
"answer": "B"
},
{
"question": "Which planet is known as the Red Planet?",
"options": {
"A": "Earth",
"B": "Venus",
"C": "Jupiter",
"D": "Mars"
},
"answer": "D"
}
]
score = 0
print("🧠 Welcome to the Quiz!\n")
for q in questions:
print(q["question"])
for key, value in q["options"].items():
print(f"{key}. {value}")
user_answer = input("Your answer (A/B/C/D): ").strip().upper()
if user_answer == q["answer"]:
print("✅ Correct!\n")
score += 1
else:
correct_option = q["options"][q["answer"]]
print(f"❌ Wrong! Correct answer: {q['answer']}. {correct_option}\n")
print(f"🎉 Quiz completed! You got {score} out of {len(questions)} correct.")
print("Thank you for playing!")