# Quiz game demo # List of questions and answers questions = [ { "question": "What is the capital of France?", "answer": "Paris" }, { "question": "What is the largest ocean in the world?", "answer": "Pacific Ocean" }, { "question": "Who painted the Mona Lisa?", "answer": "Leonardo da Vinci" }, { "question": "Which planet is known as the red planet?", "answer": "Mars" }, { "question": "What is the currency of Japan?", "answer": "Yen" } ] # Keep track of the number of correct answers correct_answers = 0 # Ask each question for question in questions: # Print the question print(question["question"]) # Get the user's answer answer = input("Your answer: ") # Check if the answer is correct if answer.lower() == question["answer"].lower(): print("Correct!") correct_answers += 1 else: print("Incorrect.") # Print the final score print("Quiz complete! You got", correct_answers, "out of", len(questions), "questions correct.")

Comments

Popular posts from this blog