gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
Write a simplest python about paper-scissors-stone game
- User
Write a simplest python about paper-scissors-stone game
- Assistant
Sure! Here's a simple implementation of the paper-scissors-stone game in Python:
import random def play_game(): choices = ['paper', 'scissors', 'stone'] computer_choice = random.choice(choices) user_choice = input("Enter your choice (paper/scissors/stone): ").lower() print("Computer's choice:", computer_choice) print("Your choice:", user_choice) if user_choice == computer_choice: print("It's a tie!") elif user_choice == 'paper' and computer_choice == 'stone': print("You win!") elif user_choice == 'scissors' and computer_choice == 'paper': print("You win!") elif user_choice == 'stone' and computer_choice == 'scissors': print("You win!") else: print("Computer wins!") # Main game loop while True: play_game() again = input("Do you want to play again? (y/n): ").lower() if again != 'y': breakThis code imports the
randommodule to randomly choose the computer's choice between paper, scissors, and stone. The user is prompted to enter their choice, and the computer's choice is then compared to determine the winner. The game loop allows the user to play multiple rounds until they choose to exit.