Shop Amazon

Sunday, July 2, 2023

Jeopardy

Jeopardy Game import random def generate_question(category, value): """Generates a question and answer for the given category and value.""" question = "What is the " + value + " for " + category + "?" answer = random.randint(1, 1000) return question, answer def play_game(): """Plays a game of Jeopardy.""" categories = ["History", "Science", "Geography", "Pop Culture"] values = ["$200", "$400", "$600", "$800", "$1000"] questions = [] for category in categories: for value in values: question, answer = generate_question(category, value) questions.append((question, answer)) player_1 = input("Player 1, what is your name? ") player_2 = input("Player 2, what is your name? ") scores = {player_1: 0, player_2: 0} for question, answer in questions: print(question) player = input("Who is answering? ") if player == player_1: guess = input("Your guess: ") if guess == str(answer): scores[player_1] += value else: scores[player_2] += value elif player == player_2: guess = input("Your guess: ") if guess == str(answer): scores[player_2] += value else: scores[player_1] += value print("The final scores are:") print(player_1, scores[player_1]) print(player_2, scores[player_2]) if __name__ == "__main__": play_game() import random # Sample Jeopardy categories and questions categories = { "Movies": [ {"question": "This film won the Best Picture Oscar in 2021.", "answer": "Nomadland"}, {"question": "Which actor played Tony Stark in the Iron Man movies?", "answer": "Robert Downey Jr."}, # Add more questions... ], "Sports": [ {"question": "Who holds the record for the most home runs in baseball?", "answer": "Barry Bonds"}, {"question": "Which country hosted the 2018 FIFA World Cup?", "answer": "Russia"}, # Add more questions... ], # Add more categories... } def select_question(): category = random.choice(list(categories.keys())) question = random.choice(categories[category]) return category, question def play_jeopardy(): score = 0 num_questions = 5 # Number of questions to play for _ in range(num_questions): category, question = select_question() print(f"Category: {category}") print(f"Question: {question['question']}") user_answer = input("Your answer: ").strip().lower() if user_answer == question['answer'].lower(): print("Correct!") score += 1 else: print(f"Wrong! The correct answer is: {question['answer']}") print() print(f"Final Score: {score}/{num_questions}") # Play the game play_jeopardy()

Jeopardy Game

History

  • $200: What is the Magna Carta?
  • $400: What is the name of the first president of the United States?
  • $600: What is the capital of France?
  • $800: What is the name of the first woman to win the Nobel Prize?
  • $1000: What is the name of the largest ocean in the world?

Science

  • $200: What is the scientific name for the platypus?
  • $400: What is the speed of light?
  • $600: What is the name of the largest planet in the solar system?
  • $800: What is the name of the element with the atomic number 6?
  • $1000: What is the name of the force that keeps us on the ground?

Geography

  • $200: What is the highest mountain in the world?
  • $400: What is the largest continent in the world?
  • $600: What is the capital of Japan?
  • $800: What is the name of the longest river in the world?
  • $1000: What is the name of the largest ocean in the world?

Pop Culture

  • $200: What is the name of the lead singer of the Beatles?
  • $400: What is the name of the actor who played Batman in the 1989 movie?
  • $600: What is the name of the character played by Jennifer Lawrence in the movie The Hunger Games?
  • $800: What is the name of the band that sang the song "Bohemian Rhapsody"?
  • $1000: What is the name of the movie that won the most Academy Awards?

No comments:

Post a Comment