At Westonci.ca, we connect you with the answers you need, thanks to our active and informed community. Connect with a community of experts ready to provide precise solutions to your questions on our user-friendly Q&A platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

Randomly choose rock, paper, or scissors for the computer
Ask the user to choose rock, paper, or scissors
Compare the computer’s choice to the player’s choice
Announce whether the computer or the human won
( In python.)


Sagot :

import random

computer_choice = random.choice(["rock", "paper", "scissors"])

user_choice = input("rock, paper, or scissors? ")

if computer_choice == user_choice:

   print("It's a draw!")

elif user_choice == "rock" and computer_choice == "scissors":

   print("You win!")

elif user_choice == "paper" and computer_choice == "rock":

   print("You win!")

elif user_choice == "scissors" and computer_choice == "paper":

   print("You win!")

else:

   print("The computer wins!")

I wrote my code in python 3.8. I hope this helps.