└── game.py /game.py: -------------------------------------------------------------------------------- 1 | # Python-quiz-game 2 | This is the basic outline to implement a simple quiz game using python codings 3 | i used three questions within the code to implement this game 4 | 5 | 6 | class Quiz: 7 | def __init__(self, questions): 8 | self.questions = questions 9 | self.score = 0 10 | def display_question(self, question): 11 | print(question) 12 | def display_result(self): 13 | print(f"Your final score is: {self.score}/{len(self.questions)}") 14 | def run_quiz(self): 15 | for question, answer in self.questions.items(): 16 | self.display_question(question) 17 | user_answer = input("Your answer: ") 18 | if user_answer.lower() == answer.lower(): 19 | print("Correct!") 20 | self.score += 1 21 | else: 22 | print("Incorrect.") 23 | self.display_result() 24 | quiz_data = { 25 | "What is the capital of France?": "Paris", 26 | "What is 100 + 200": "300", 27 | "Who painted the Mona Lisa?": "Leonardo da Vinci" 28 | } 29 | quiz = Quiz(quiz_data) 30 | quiz.run_quiz() 31 | --------------------------------------------------------------------------------