-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_10_quiz_game_2.py
52 lines (46 loc) · 1.3 KB
/
project_10_quiz_game_2.py
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
# Project 10
# Quiz program
quiz = {
"question1":{
"question":"What is the capital city of Bangladesh?",
"answer":"Dhaka"
},
"question2":{
"question":"What is the capital city of Denmark?",
"answer":"Copenhagen"
},
"question3":{
"question":"What is the capital city of Japan?",
"answer":"Tokyo"
},
"question4":{
"question":"What is the capital city of USA?",
"answer":"Washington"
},
"question5":{
"question":"What is the capital city of Russia?",
"answer":"Moscow"
},
"question6":{
"question":"What is the capital city of Spain?",
"answer":"Madrid"
}
}
# print(quiz)
score = 0
for key, value in quiz.items():
print(value["question"])
answer = input("Answer? ")
if answer.lower() == value["answer"].lower():
print("Correct")
score = score + 1
print("Your score is " + str(score))
print("")
else:
print("Wrong!")
print("The answer is: " + value['answer'])
print("Your score is " + str(score))
print("")
print("You got " + str(score) + " out of " + str(len(quiz)) + " qustions correctly!")
print("Your percentage is " + str(int(score/len(quiz) *100)) + "% !")
print("Thanks for playing the quiz!\n")