Python icon indicating copy to clipboard operation
Python copied to clipboard

משחק מחשב מתמטיקה

Open nogazagagi opened this issue 7 months ago • 0 comments

class Question: def init(self, prompt, answer): self.prompt = prompt self.answer = answer

questions = [ Question("What is the capital of France?\n(a) Paris\n(b) London\n(c) Berlin\n", "a"), Question("What is 2 + 2?\n(a) 2\n(b) 3\n(c) 4\n", "c"), Question("Who wrote 'Romeo and Juliet'?\n(a) Charles Dickens\n(b) William Shakespeare\n(c) Jane Austen\n", "b") ]

def run_quiz(questions): score = 0 for question in questions: answer = input(question.prompt).lower() if answer == question.answer: score += 1 print("Correct!\n") else: print("Incorrect. The correct answer was: {}\n".format(question.answer))

print("You got {}/{} correct answers.".format(score, len(questions)))

run_quiz(questions)

nogazagagi avatar Jul 14 '24 08:07 nogazagagi