Quiz Stored in dictionary
question_and_answer = []
question_and_answer.append({
"Question": "What is the shape of the earth?",
"Answer": "sphere"
})
question_and_answer.append({
"Question": "What is the innermost layer of earth?",
"Answer": "core"
})
question_and_answer.append({
"Question": "Is global warming bad?",
"Answer": "yes"
})
totalquestions = len(question_and_answer)
print("This is a quiz with a total of " + str(totalquestions) + " questions.")
score = 0
for record in question_and_answer:
msg = input(record["Question"])
if (msg == record["Answer"]):
print ("You are correct!")
score = score + 1
else:
print ("Wrong. The correct answer is: " + record["Answer"])
print("Your total score is:" + str(score) + " out of " + str(totalquestions))