diff --git a/sami/learn-python-the-hard-way/__pycache__/Question.cpython-37.pyc b/sami/learn-python-the-hard-way/__pycache__/Question.cpython-37.pyc new file mode 100644 index 0000000..059710a Binary files /dev/null and b/sami/learn-python-the-hard-way/__pycache__/Question.cpython-37.pyc differ diff --git a/sami/learn-python-the-hard-way/learn-german.org b/sami/learn-python-the-hard-way/learn-german.org index ef55b89..6a47b3c 100644 --- a/sami/learn-python-the-hard-way/learn-german.org +++ b/sami/learn-python-the-hard-way/learn-german.org @@ -7,3 +7,18 @@ * Prepositions ** This game can be about prepositions *** The quiz is gets verb and choices and then chooses the best answer. + +- My Game Description +- I want to program a translation Quiz +- Game flow is: + - The Quiz shows a german word + - It prompts for a translation + - The player enters the translation + - Quiz compares + - The Quiz outputs write or wrong + - The Quiz Counts your points + - For a correct answer player get plus 5 points + - For incorrect answer player gets minus 3 points + - The Quiz ends when player types quit + - When you quit the Quiz shows the total points + - ( optional) The Quiz shows total amount of write and wrong answers diff --git a/sami/learn-python-the-hard-way/quiz.py b/sami/learn-python-the-hard-way/quiz.py new file mode 100644 index 0000000..cc40132 --- /dev/null +++ b/sami/learn-python-the-hard-way/quiz.py @@ -0,0 +1,23 @@ +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)