import random def random_trivia_game(): print("Welcome to the Random Trivia Quiz Game!") # List of trivia questions and their answers trivia_questions = [ { "question": "What is the capital of France?", "options": ["Berlin", "Madrid", "Paris", "Rome"], "answer": "Paris" }, { "question": "Who wrote 'Romeo and Juliet'?", "options": ["Shakespeare", "Dickens", "Hemingway", "Austen"], "answer": "Shakespeare" }, { "question": "What is the largest planet in our solar system?", "options": ["Earth", "Mars", "Jupiter", "Saturn"], "answer": "Jupiter" }, { "question": "Which element has the chemical symbol 'O'?", "options": ["Oxygen", "Osmium", "Ozone", "Opium"], "answer": "Oxygen" }, { "question": "What is the smallest country in the world?", "options": ["Monaco", "Vatican City", "Nauru", "Tuvalu"], "answer": "Vatican City" } ] # Pick a random trivia question question = random.choice(trivia_questions) print("\n" + question["question"]) print("Options: ") # Display the options for the question for i, option in enumerate(question["options"], 1): print(f"{i}. {option}") # Get the user's answer user_answer = input("Enter the number of your answer: ") # Validate the answer try: user_answer = int(user_answer) if 1 <= user_answer <= len(question["options"]): if question["options"][user_answer - 1] == question["answer"]: print("Correct! Well done.") else: print(f"Oops! The correct answer was: {question['answer']}") else: print("Invalid option. Please enter a number from the options.") except ValueError: print("Please enter a valid number.") print("Thanks for playing the Random Trivia Quiz!") if __name__ == "__main__": random_trivia_game()