Quiz using list of dictionaries
def Python_Quiz(prompt):
global word
print ("Question: " + prompt)
word = input()
return word
questions_number = 4
correct_answer = 0
print("Hello, you will now be answering " + str(questions_number) + " questions")
My_Quiz = [{
"How many states are in the United States of America?": "50",
"What is the absolute value of 9?": "9",
"What is the first colour in a rainbow?": "red",
"What is the 21st letter of the alphabet?": "u",
}]
# My_Quiz.append({
# "How many states are in the United States of America?": "50",
# "What is the absolute value of 9?": "9",
# "What is the first colour in a rainbow?": "red",
# "What is the 21st letter of the alphabet?": "u",
# })
for dict in My_Quiz:
for questions, answers in dict.items():
Python_Quiz(questions)
if word == answers:
print("That is correct")
correct_answer += 1
else:
print("That is incorrect")
print("You answered " + str(correct_answer) + " out of " + str(questions_number)+ " questions correctly")