Skip to content

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

@nogazagagi

Description

@nogazagagi

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions