ungleich-learning-circle/sami/learn-python-the-hard-way/quiz.py

24 lines
746 B
Python
Raw Normal View History

2020-06-24 14:41:27 +00:00
class Question:
def __init__(self, prompt, answer):
self.prompt = prompt
self.answer = answer
question_prompts = [
"Which word does not much with the German verb aufsatzen?\n(a) to put on\n(b) to set up\n(c) to sit up\n(d) to stop",
"which word does not much with the German verb absagen?\n(a) to cancel\n(b) to refuse\n(c) to decline\n(d) to approve",
]
questions = [
Question(question_prompts[0], "d"),
Question(question_prompts[1], "d"),
]
def run_quiz(questions):
score = 0
for question in questions:
answer = input(question.prompt)
if answer == question.answer:
score += 1
print("you got", score, "out of", len(questions))
run_quiz(questions)