-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
87 lines (84 loc) · 3.47 KB
/
main.py
File metadata and controls
87 lines (84 loc) · 3.47 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
def run_quiz():
questions = [
{
"question": "What is the capital of France?",
"options": ["A) Berlin", "B) Madrid", "C) Paris", "D) Rome"],
"answer": "C)Paris"
},
{
"question": "Who wrote '1984'?",
"options": ["A) George Orwell", "B) Aldous Huxley", "C) Ray Bradbury", "D) J.G. Ballard"],
"answer": "A)George Orwell"
},
{
"question": "Who wrote 'To Kill a Mockingbird'?",
"options": ["A) Harper Lee", "B) Mark Twain", "C) J.K. Rowling", "D) Ernest Hemingway"],
"answer": "A)Harper Lee"
},
{
"question": "What is the chemical symbol for water?",
"options": ["A) H2O", "B) CO2", "C) O2", "D) NaCl"],
"answer": "A)H2O"
},
{
"question": "Who painted the Mona Lisa?",
"options": ["A) Vincent van Gogh", "B) Pablo Picasso", "C) Leonardo da Vinci", "D) Michelangelo"],
"answer": "C)Leonardo da Vinci"
},
{
"question": "Who wrote 'The Lord of the Rings'?",
"options": ["A) J.R.R. Tolkien", "B) C.S. Lewis", "C) George Orwell", "D) J.K. Rowling"],
"answer": "A)J.R.R. Tolkien"
},
{
"question": "What is the smallest prime number?",
"options": ["A) 0", "B) 1", "C) 2", "D) 3"],
"answer": "C)2"
},
{
"question": "Who is known as the 'Father of Computers'?",
"options": ["A) Alan Turing", "B) Charles Babbage", "C) Bill Gates", "D) Steve Jobs"],
"answer": "B)Charles Babbage"
},
{
"question": "Who wrote 'Harry Potter'?",
"options": ["A) J.K. Rowling", "B) Stephen King", "C) George Orwell", "D) Ernest Hemingway"],
"answer": "A)J.K. Rowling"
},
{
"question": "Who wrote 'The Great Gatsby'?",
"options": ["A) F. Scott Fitzgerald", "B) Ernest Hemingway", "C) J.D. Salinger", "D) Mark Twain"],
"answer": "A)F. Scott Fitzgerald"
},
{
"question": "Who wrote 'Hamlet'?",
"options": ["A) William Shakespeare", "B) Charles Dickens", "C) Jane Austen", "D) Leo Tolstoy"],
"answer": "A)William Shakespeare"
},
{
"question": "Who wrote 'The Game of Thrones'?",
"options": ["A) J.R.R. Tolkien", "B) George R.R. Martin", "C) J.K. Rowling", "D) Stephen King"],
"answer": "B)George R.R. Martin"
},
{
"question": "Who wrote 'A Court of Thorns and Roses'?",
"options": ["A) Sarah J. Maas", "B) J.K. Rowling", "C) George R.R. Martin", "D) Stephen King"],
"answer": "A)Sarah J. Maas"
}
]
score = 0
for index, q in enumerate(questions):
# print(index, q["question"])
print(f"\nQ. {index + 1}: {q['question']}")
for option in q["options"]:
print(option)
answer = input("Your answer (Enter A/B/C/D) : ")
if answer.strip().upper() == q["answer"][0]:
print("\nCorrect!")
score += 1
else: print(f"\nWrong! The correct answer is: {q['answer']}")
print(f"\nYou selected: {answer.strip().upper()}")
print(f"Correct answer: {q['answer']}")
print(f"Current Score: {score}/{index + 1}")
print(f"\nQuiz Completed! Your Final Score: {score}/{len(questions)}\n")
run_quiz()