Learning-cicle/sami/learn-python-the-hard-way/quiz.py

62 lines
2.6 KiB
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 = [
2020-06-25 13:46:41 +00:00
"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: ",
2020-06-24 14:41:27 +00:00
]
questions = [
Question(question_prompts[0], "d"),
Question(question_prompts[1], "d"),
2020-06-25 13:46:41 +00:00
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"),
2020-06-24 14:41:27 +00:00
]
2020-06-26 13:58:27 +00:00
def quiz(questions):
2020-06-24 14:41:27 +00:00
score = 0
for question in questions:
answer = input(question.prompt)
if answer == question.answer:
2020-06-25 13:46:41 +00:00
score += 5
print("Correct! Your score is", score,)
2020-06-26 13:58:27 +00:00
2020-06-25 13:46:41 +00:00
else:
print("Incorrect!")
score -= 3
print("You lost 3 points!")
print ("Score: ", score)
print ("\n")
2020-06-26 13:58:27 +00:00
# Final stage
score = 0
if score >= -30:
print("Your total score is:", score, "- You suck!")
2020-06-25 13:46:41 +00:00
2020-06-26 13:58:27 +00:00
elif score == 10 or 15 :
print("Your total score is:", score, "- You went ok!")
2020-06-25 13:46:41 +00:00
2020-06-26 13:58:27 +00:00
else:
print("Your total score is:", score, "- You are awesome!")
2020-06-25 13:46:41 +00:00
2020-06-26 13:58:27 +00:00
quiz(questions)