Discover answers to your questions with Westonci.ca, the leading Q&A platform that connects you with knowledgeable experts. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.
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")
We appreciate your time. Please come back anytime for the latest information and answers to your questions. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. We're dedicated to helping you find the answers you need at Westonci.ca. Don't hesitate to return for more.