You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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))
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))
run_quiz(questions)
The text was updated successfully, but these errors were encountered: