Learning-cicle/sami/learn-python-the-hard-way/quiz.py
2020-06-25 15:46:41 +02:00

53 lines
2.4 KiB
Python

class Question:
def __init__(self, prompt, answer):
self.prompt = prompt
self.answer = answer
question_prompts = [
"Which word does not match with the German verb aufsetzen? \n(a) to put on \n(b) to set up \n(c) to sit up \n(d) to stop \nAnswer: ",
"which word does not match with the German verb absagen? \n(a) to cancel \n(b) to refuse \n(c) to decline \n(d) to approve \nAnswer: ",
"Which word does not match with the German verb umsteigen? \n(a) to transfer \n(b) to change \n(c) to stay \n(d) to switch \nAnswer: ",
"Which word does not match with the German verb abbiegen? \n(a) to return \n(b) to to bend \n(c) to turn off \n(d) to turn\nAnswer: ",
"Which word does not match with the German verb anbieten? \n(a) to offer \n(b) to demand \n(c) to proffer \n(d) volunteer \nAnswer: ",
"Which word does not match with the German verb beitragen? \n(a) to obligate \n(b) to redound \n(c) to help \n(d) contribute \nAnswer: ",
"Which word does not match with the German verb weiterleiten? \n(a) to forward \n(b) to send \n(c) to pass on\n(d) to replace \nAnswer: ",
"Which word does not match with the German verb abziehen? \n(a) to remove \n(b) to deduct \n(c) to top up \n(d) pull off \nAnswer: ",
"Which word does not match with the German verb anpassen? \n(a) to adjust \n(b) to repair \n(c) to customize \n(d) to adapt \nAnswer: ",
"Which word does not match with the German verb umsetzen? \n(a) to destroy \n(b) to implement \n(c) to translate \n(d) to convert \nAnswer: ",
]
questions = [
Question(question_prompts[0], "d"),
Question(question_prompts[1], "d"),
Question(question_prompts[2], "c"),
Question(question_prompts[3], "a"),
Question(question_prompts[4], "b"),
Question(question_prompts[5], "a"),
Question(question_prompts[6], "d"),
Question(question_prompts[7], "c"),
Question(question_prompts[8], "b"),
Question(question_prompts[9], "a"),
]
def run_quiz(questions):
score = 0
for question in questions:
answer = input(question.prompt)
if answer == question.answer:
score += 5
print("Correct! Your score is", score,)
else:
print("Incorrect!")
score -= 3
print("You lost 3 points!")
print ("Score: ", score)
print ("\n")
run_quiz(questions)