-
Notifications
You must be signed in to change notification settings - Fork 0
/
quiz program.py
49 lines (45 loc) · 1.31 KB
/
quiz program.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
quiz = {
"question1": {
"question": "What is the capital of France?",
"answer": "Paris"
},
"question2": {
"question": "What is the capital of Germany?",
"answer": "Berlin"
},
"question3": {
"question": "What is the capital of Italy?",
"answer": "Rome"
},
"question4": {
"question": "What is the capital of Spain?",
"answer": "Madrid"
},"question5": {
"question": "What is the capital of Portugal?",
"answer": "Lisbon"
},"question6": {
"question": "What is the capital of Switzerland?",
"answer": "Bern"
},"question7": {
"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')
score = score + 1
print("Your score is: " + str(score))
print("")
print("")
else:
print("Wrong!")
print("The answer is : " + value[ ' answer'])
print("Your score is: " + str(score))
print("")
print("")
print("You got " + str(score) + " out of 7 questions correctly")
print("Your percentage is " + str(int(score/7 * 100)) + "%")