Question: I am having a hard time getting my code to work to match the outputs in the image. Below is my current code. Please rewrite
I am having a hard time getting my code to work to match the outputs in the image. Below is my current code. Please rewrite the code to work correctly. Thanks
import random
ROCK
PAPER
SCISSORS
# Read random seed to support testing do not alter and starting credits
seed intinput
# Set the seed for random
random.seedintseed
# Read player names and number of rounds
playername input
playername input
rounds intinput
# Ensure rounds is positive
while rounds :
printRounds must be
rounds intinput
printfplayername vs playername for rounds rounds"
# Play rounds
playerwins
playerwins
ties
for in rangerounds:
# Generate random hand signals for both players
psignal random.randint
psignal random.randint
# Convert hand signals to string
handmap
ROCK: "rock",
PAPER: "paper",
SCISSORS: "scissors"
# Convert hand signals to string
phand handmappsignal
phand handmappsignal
if psignal ROCK:
if psignal SCISSORS:
printfplayername wins with rock"
else:
printfplayername wins with paper"
elif psignal PAPER:
if psignal ROCK:
printfplayername wins with paper"
else:
printfplayername wins with scissors"
else: # psignal SCISSORS
if psignal PAPER:
printfplayername wins with scissors"
else:
printfplayername wins with rock"
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
