-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
class Question:
def init(self, prompt, answer):
self.prompt = prompt
self.answer = answer
questions = [
Question("What is the capital of France?\n(a) Paris\n(b) London\n(c) Berlin\n", "a"),
Question("What is 2 + 2?\n(a) 2\n(b) 3\n(c) 4\n", "c"),
Question("Who wrote 'Romeo and Juliet'?\n(a) Charles Dickens\n(b) William Shakespeare\n(c) Jane Austen\n", "b")
]
def run_quiz(questions):
score = 0
for question in questions:
answer = input(question.prompt).lower()
if answer == question.answer:
score += 1
print("Correct!\n")
else:
print("Incorrect. The correct answer was: {}\n".format(question.answer))
print("You got {}/{} correct answers.".format(score, len(questions)))
run_quiz(questions)
Metadata
Metadata
Assignees
Labels
No labels