-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9 - Create a Quiz Game with Python.py
More file actions
57 lines (43 loc) · 1.59 KB
/
9 - Create a Quiz Game with Python.py
File metadata and controls
57 lines (43 loc) · 1.59 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
questions = ("How many elements are in the periodic table?",
"Which animal lays the largest eggs?",
"What is the most abundant gas in Earth's atmosphere?",
"How many bones are in the human body?",
"Which planet is known as the Red Planet?",
)
options = (("A. 116", "B. 117", "C. 118", "D. 119"),
("A. Whale", "B. Crocodile", "C. Ostrich", "D. Penguin"),
("A. Nitrogen", "B. Oxygen", "C. Carbon Dioxide", "D. Argon"),
("A. 206", "B. 207", "C. 208", "D. 209"),
("A. Venus", "B. Mars", "C. Jupiter", "D. Saturn"),
())
answers = ("C", "C", "A", "A", "B",)
guesses = []
score = 0
question_num = 0
for question in questions:
print("-------------------------")
print(question)
for option in options[question_num]:
print(option)
guess = input("Enter(A, B, C, D): ").upper()
guesses.append(guess)
if guess == answers[question_num]:
score +=1
print("✅ CORRECT!")
else:
print("❌INCORRECT!")
print(f"{answers[question_num]} is the correct answer.")
question_num += 1
print("-------------------------")
print(" RESULTS ")
print("-------------------------")
print("answers: ", end="")
for answer in answers:
print(answer, end=" ")
print()
print("guesses: ", end="")
for guess in guesses:
print(guess, end=" ")
print()
score_percentage = int((score/len(questions)) * 100)
print(f"Your score is: {score}/{len(questions)} ({score_percentage}%)")