-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython Quiz game.py
More file actions
172 lines (137 loc) · 5 KB
/
Copy pathPython Quiz game.py
File metadata and controls
172 lines (137 loc) · 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#Python quiz game
questions =("How many elements are in the periodic table?: ",
"Which animal lays the largest eggs?: ",
"What is the most abundant gas in Earth's atnosphere?: ",
"How many bones are in the human body?: ",
"Which planet in the solar system is the hottest?: ")
options = (("A. 116", "B. 117", "C. 118", "D. 119"),
("A. Whale", "B. Crocodile", "C. Elephant", "D. Ostrich"),
("A. Nitrogen", "B. Oxygen", "C. Carbon-Dioxide", "D. Hydrogen"),
("A. 206", "B. 207", "C. 208", "D. 209"),
("A. Mecury", "B. Venus", "C. Earth", "D. Mars"))
answers = ("C", "D", "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 = int(score / len(questions) * 100)
print(f"Your score is: {score}%")
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 in the solar system is the hottest?: ",
"What is the chemical symbol for gold?: ",
"Which organ pumps blood through the body?: ",
"What is the powerhouse of the cell?: ",
"How many continents are there on Earth?: ",
"Which ocean is the largest?: ",
"What is the capital of France?: ",
"How many legs does a spider have?: ",
"Which gas do plants absorb from the atmosphere?: ",
"What is the boiling point of water in Celsius?: ",
"Who developed the theory of relativity?: ",
"Which instrument measures atmospheric pressure?: ",
"Which part of the human body contains the most bones?: ",
"What is the hardest natural substance on Earth?: ",
"Which planet is known as the Red Planet?: ",
"What is the capital of Japan?:"
)
options = (
("A. 116", "B. 117", "C. 118", "D. 119"),
("A. Whale", "B. Crocodile", "C. Elephant", "D. Ostrich"),
("A. Nitrogen", "B. Oxygen", "C. Carbon-Dioxide", "D. Hydrogen"),
("A. 206", "B. 207", "C. 208", "D. 209"),
("A. Mercury", "B. Venus", "C. Earth", "D. Mars"),
("A. Au", "B. Ag", "C. Fe", "D. Pb"),
("A. Liver", "B. Heart", "C. Brain", "D. Kidney"),
("A. Nucleus", "B. Mitochondria", "C. Ribosome", "D. Cytoplasm"),
("A. 5", "B. 6", "C. 7", "D. 8"),
("A. Atlantic", "B. Indian", "C. Arctic", "D. Pacific"),
("A. Rome", "B. London", "C. Paris", "D. Berlin"),
("A. 6", "B. 8", "C. 10", "D. 12"),
("A. Oxygen", "B. Carbon-Dioxide", "C. Hydrogen", "D. Nitrogen"),
("A. 90", "B. 100", "C. 110", "D. 120"),
("A. Newton", "B. Einstein", "C. Galileo", "D. Tesla"),
("A. Thermometer", "B. Barometer", "C. Hygrometer", "D. Anemometer"),
("A. Skull", "B. Spine", "C. Hands", "D. Feet"),
("A. Gold", "B. Iron", "C. Diamond", "D. Silver"),
("A. Mars", "B. Jupiter", "C. Saturn", "D. Uranus"),
("A. Seoul", "B. Beijing", "C. Tokyo", "D. Bangkok")
)
answers = ("C", "D", "A", "A", "B", "A", "B", "B", "D", "D", "C", "B", "B", "B", "B", "B", "D", "C", "A", "C")
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: ", " ".join(answers))
print("Guesses: ", " ".join(guesses))
print("\nYou scored", score, "out of 20!")
if score >= 18:
grade = "A1"
print(f"Excellent! You got {grade}!")
elif score >= 16:
grade = "B2"
print(f"Great job! You got {grade}!")
elif score >= 14:
grade = "B3"
print(f"Good effort! You got {grade}!")
elif score >= 12 :
grade = "C4"
print(f"Nice work! You got {grade}!")
elif score >= 10:
grade = "C5"
print(f"Keep it up! You got {grade}!")
elif score >= 8:
grade = "C6"
print(f"You passed! You got {grade}!")
elif score >= 6:
grade = "D7"
print(f"Almost there! You got {grade}!")
elif score >= 4:
grade = "E8"
print(f"Needs improvement! You got {grade}!")
else:
grade = "F9"
print(f"Better luck next time! You got {grade}!")