Answer:
import random
computer = random.randint(0, 2)
user = int(input("scissor (0), rock (1), paper (2): "))
if computer == 0:
if user == 0:
print("The computer is scissor. You are scissor too. It is a draw")
elif user == 1:
print("The computer is scissor. You are rock. You won")
elif user == 2:
print("The computer is scissor. You are paper. Computer won")
elif computer == 1:
if user == 0:
print("The computer is rock. You are scissor. Computer won")
elif user == 1:
print("The computer is rock. You are rock too. It is a draw")
elif user == 2:
print("The computer is rock. You are paper. You won")
elif computer == 2:
if user == 0:
print("The computer is paper. You are scissor. You won")
elif user == 1:
print("The computer is paper. You are rock. Computer won")
elif user == 2:
print("The computer is paper. You are paper too. It is a draw")
Explanation:
*The code is in Python.
Import the random to be able to generate number number
Generate a random number between 0 and 2 (inclusive) using randint() method and set it to the computer variable
Ask the user to enter a number and set it to the user variable
Check the value of computer the computer variable:
If it is 0, check the value of user variable. If user is 0, it is a draw. If user is 1, user wins. If user is 2, computer wins
If it is 1, check the value of user variable. If user is 0, computer wins. If user is 1, it is a draw. If user is 2, user wins
If it is 2, check the value of user variable. If user is 0, user wins. If user is 1, computer wins. If user is 2, it is a draw