Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nogazagagi opened this issue Jul 14, 2024 · 0 comments
Open

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

nogazagagi opened this issue Jul 14, 2024 · 0 comments

Comments

@nogazagagi
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant