Welcome to Westonci.ca, the Q&A platform where your questions are met with detailed answers from experienced experts. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.
Sagot :
Answer:
In Python
print("Instruction: 1. Rock, 2. Paper or 3. Scissors: ")
p1 = int(input("Player 1: "))
p2 = int(input("Player 2: "))
if p1 == p2:
print("Tie")
else:
if p1 == 1: # Rock
if p2 == 2: #Paper
print("P2 wins! Paper covers Rock")
else: #Scissors
print("P1 wins! Rock smashes Scissors")
elif p1 == 2: #Paper
if p2 == 1: #Rock
print("P1 wins! Paper covers Rock")
else: #Scissors
print("P2 wins! Scissors cuts Paper")
elif p1 == 3: #Scissors
if p2 == 1: #Rock
print("P2 wins! Rock smashes Scissors")
else: #Paper
print("P1 wins! Scissors cuts Paper")
Explanation:
This prints the game instruction
print("Instruction: 1. Rock, 2. Paper or 3. Scissors: ")
The next two lines get input from the user
p1 = int(input("Player 1: "))
p2 = int(input("Player 2: "))
If both input are the same, then there is a tie
if p1 == p2:
print("Tie")
If otherwise
else:
The following is executed if P1 selects rock
if p1 == 1: # Rock
If P2 selects paper, then P2 wins
if p2 == 2: #Paper
print("P2 wins! Paper covers Rock")
If P2 selects scissors, then P1 wins
else: #Scissors
print("P1 wins! Rock smashes Scissors")
The following is executed if P1 selects paper
elif p1 == 2: #Paper
If P2 selects rock, then P1 wins
if p2 == 1: #Rock
print("P1 wins! Paper covers Rock")
If P2 selects scissors, then P2 wins
else: #Scissors
print("P2 wins! Scissors cuts Paper")
The following is executed if P1 selects scissors
elif p1 == 3: #Scissors
If P2 selects rock, then P2 wins
if p2 == 1: #Rock
print("P2 wins! Rock smashes Scissors")
If P2 selects paper, then P1 wins
else: #Paper
print("P1 wins! Scissors cuts Paper")
Visit us again for up-to-date and reliable answers. We're always ready to assist you with your informational needs. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Get the answers you need at Westonci.ca. Stay informed by returning for our latest expert advice.