-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquiz.py
51 lines (46 loc) · 1.25 KB
/
quiz.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
quiz = {
"question1": {
"question": "what is the capital of France?",
"answer": "Paris"
},
"question2": {
"question": "what is the capital of England?",
"answer": "London"
},
"question3": {
"question": "what is the capital of Germany?",
"answer": "Berlin"
},
"question4": {
"question": "what is the capital of Spain?",
"answer": "Madrid"
},
"question5": {
"question": "what is the capital of India?",
"answer": "Delhi"
},
"question6": {
"question": "what is the capital of Turkey?",
"answer": "Ankara"
},
"question7": {
"question": "what is the capital of Nigeria?",
"answer": "Lagos"
},
}
score = 0
for key, value in quiz.items():
print(value['question'])
answer = input('Answer? ')
if answer.lower() == value['answer'].lower():
print('Correct')
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('Your total score is ' + str(score) + ' out of 7')
print('Your percentage is ' + str(score/7 * 100) + '%')