Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Get quick and reliable answers to your questions from a dedicated community of professionals on our platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.
Sagot :
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
Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.