From 9c213de08da454297d93961084199a4cc6e95620 Mon Sep 17 00:00:00 2001 From: samuel Date: Wed, 24 Jun 2020 16:41:27 +0200 Subject: [PATCH] wrote the fist code of the quiz --- .../__pycache__/Question.cpython-37.pyc | Bin 0 -> 1029 bytes .../learn-german.org | 15 ++++++++++++ sami/learn-python-the-hard-way/quiz.py | 23 ++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 sami/learn-python-the-hard-way/__pycache__/Question.cpython-37.pyc create mode 100644 sami/learn-python-the-hard-way/quiz.py 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 0000000000000000000000000000000000000000..059710a19630659426551c8f2d765e71fa2fe683 GIT binary patch literal 1029 zcmb7DL2uJA6tL$n?vc53jzd_cAEqoCRKvSi`_OXu`}CQX_cP3Kf@p3 z$N0)=XHIb9y>x|%8?OBF`PuJ#etuuy937;)nbhqq)J%1{PdN{L86knGVN z@RE%B8#S`IsxalqL&(WMwro7;doUuf)Xg`E@#3=vq!Juggg#xlyH>kBhRX z9{R@3$}O}SyM-JtxDn$eUrqM)JZn}y$@5Z`F3*wQB0r%qU7!3pv)@0@B0Q{kE%V%` zd0uPLR)~jre%ZKO~3o?c`B^v)-y zRnX*eeFFLH5DcLaP5a-F8vF}@KKhpW<2_TpQ?fM})Sr1ki%()u7e0BhQ_@Q;$UX)$ Pq>tl(#?g=-he`4q;yC(c literal 0 HcmV?d00001 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)