wrote the fist code of the quiz
This commit is contained in:
parent
b48dccca84
commit
9c213de08d
Binary file not shown.
|
@ -7,3 +7,18 @@
|
||||||
* Prepositions
|
* Prepositions
|
||||||
** This game can be about prepositions
|
** This game can be about prepositions
|
||||||
*** The quiz is gets verb and choices and then chooses the best answer.
|
*** 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
|
||||||
|
|
|
@ -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)
|
Loading…
Reference in New Issue