-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquiz_program.py
More file actions
51 lines (48 loc) · 1.38 KB
/
quiz_program.py
File metadata and controls
51 lines (48 loc) · 1.38 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
# Dictionary that stores questions and answers
# Have a variable that tracks the score of the player
# Loop through the Dictionary using the key values pairs
# Display each question to the user and allow them to answer
# Tell them if they are right or wrong
# Show the final result when quiz is completed
quiz = {
"q1": {
"question": "What is the capital of France?",
"answer": "Paris"
},
"q2": {
"question": "What is the capital of Germany?",
"answer": "Berlin"
},
"q3": {
"question": "What is the capital of Italy?",
"answer": "Rome"
},
"q4": {
"question": "What is the capital of Spain?",
"answer": "Madrid"
},
"q5": {
"question": "What is the capital of Portugal?",
"answer": "Lisbon"
},
"q6": {
"question": "What is the capital of Switzerland?",
"answer": "Bern"
},
"q7": {
"question": "What is the capital of Austria?",
"answer": "Vienna"
},
}
score = 0
for key, value in quiz.items():
print(value['question'])
answer = input("Answer: ")
if answer.lower() == value['answer'].lower():
print("Correct!\n")
score += 1
else:
print("Wrong!")
print("The answer is: " + value['answer'] + "\n")
print("Your score is: " + str(score))
print("Your percentage is: " + str(int(score/7*100)) + "%")