From 38839f5d3bf04fb79198be5ca438bc11a4cc62d1 Mon Sep 17 00:00:00 2001 From: samuel Date: Thu, 25 Jun 2020 15:46:41 +0200 Subject: [PATCH] added quiz.py more codes --- sami/learn-python-the-hard-way/.#quiz2.py | 1 + .../learn-german.org | 8 ++++ sami/learn-python-the-hard-way/quiz.py | 38 +++++++++++++++++-- sami/learn-python-the-hard-way/quiz2.py | 16 ++++++++ 4 files changed, 59 insertions(+), 4 deletions(-) create mode 120000 sami/learn-python-the-hard-way/.#quiz2.py create mode 100644 sami/learn-python-the-hard-way/quiz2.py diff --git a/sami/learn-python-the-hard-way/.#quiz2.py b/sami/learn-python-the-hard-way/.#quiz2.py new file mode 120000 index 0000000..d7a8c4f --- /dev/null +++ b/sami/learn-python-the-hard-way/.#quiz2.py @@ -0,0 +1 @@ +sami@afro-linux-lenovo-b50-30.18673:1593006374 \ No newline at end of file diff --git a/sami/learn-python-the-hard-way/learn-german.org b/sami/learn-python-the-hard-way/learn-german.org index 6a47b3c..0c686f7 100644 --- a/sami/learn-python-the-hard-way/learn-german.org +++ b/sami/learn-python-the-hard-way/learn-german.org @@ -22,3 +22,11 @@ - 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 +* Final stage +# Final stage +if score <= 1: + print("Your total score is:", score, "- You suck!") +elif score == 2: + print("Your total score is:", score, "- You went ok!") +else + print("Your total score is:", score, "- You are awesome!") diff --git a/sami/learn-python-the-hard-way/quiz.py b/sami/learn-python-the-hard-way/quiz.py index cc40132..de9505e 100644 --- a/sami/learn-python-the-hard-way/quiz.py +++ b/sami/learn-python-the-hard-way/quiz.py @@ -4,13 +4,29 @@ class Question: 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", + "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): @@ -18,6 +34,20 @@ def run_quiz(questions): for question in questions: answer = input(question.prompt) if answer == question.answer: - score += 1 - print("you got", score, "out of", len(questions)) + 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) diff --git a/sami/learn-python-the-hard-way/quiz2.py b/sami/learn-python-the-hard-way/quiz2.py new file mode 100644 index 0000000..ad92438 --- /dev/null +++ b/sami/learn-python-the-hard-way/quiz2.py @@ -0,0 +1,16 @@ +score = 0 + +# QUESTION 1 +input ("Which verb 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: + +if answer1 == "d" or answer1 == "to stop": + score += 5 + print ("Correct!") + print ("Score: ", score) + print ("\n") +else: + print("Incorrect! The answer is choice (d) or to stop) + score -= 3 + print("You lost 3 points!") + print ("Score: ", score) + print ("\n")