-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquiz.py
More file actions
34 lines (27 loc) · 836 Bytes
/
quiz.py
File metadata and controls
34 lines (27 loc) · 836 Bytes
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
questions_dict = {
'question1' : {
'Q' : 'What is the first letter of word "Shirt"',
'answer' : 's'
},
'question2' : {
'Q' : 'Where does a dog live?',
'answer' : 'kennel'
},
'question3' : {
'Q' : 'After how many years does a leap year come?',
'answer' : '4'
}
}
points = 0
print("\nWelcome To Quiz!\n")
for key_of_question_dict, value_of_question_dict in questions_dict.items():
"""Iterates through the questions_dict and checks for the right stored answer"""
print(value_of_question_dict['Q'])
user_input = input("Answer: ").lower()
if user_input == value_of_question_dict['answer']:
print("Correct!")
points = points + 1
else:
print("Incorrect!")
print()
print(f"You've earned {points} points.")