Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import random # Step 0 : Define constants ROCK = 0 PAPER = 1 SCISSORS = 2 hand _ signal _ names = [
import random
# Step : Define constants
ROCK
PAPER
SCISSORS
handsignalnamesROCK"PAPER","SCISSORS" # define the names for each hand signal
# Read seed from input for random number generator
seedvalue intinput
random.seedseedvalue
# Step : Read player names and number of rounds
playername input
playername input
numrounds intinput
# Make sure the number of rounds is valid
while numrounds :
printRounds must be
numrounds intinput
# Output the player names and number of rounds
printfplayername vs playername for numrounds rounds"
# Step : Play the game for the specified number of rounds
playerwins
playerwins
# Loop through each round
for i in rangenumrounds:
# Generate a random hand signal for each player
playersignal random.randint
playersignal random.randint
# If both players make the same signal, it's a tie and we need to generate new signals
while playersignal playersignal:
printTie
playersignal random.randint
playersignal random.randint
# Determine the winner for this round and output a message
if playersignal ROCK and playersignal SCISSORS:
printfplayername wins with rock"
playerwins
elif playersignal SCISSORS and playersignal PAPER:
printfplayername wins with scissors"
playerwins
elif playersignal PAPER and playersignal ROCK:
printfplayername wins with paper"
playerwins
else:
printfplayername wins with handsignalnamesplayersignal
playerwins
# Output the results
printfplayername wins playerwins and playername wins playerwins
IN PYTHON PLEASE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started