Question: import random # Step 0 : Define constants ROCK = 0 PAPER = 1 SCISSORS = 2 hand _ signal _ names = [

import random
# Step 0: Define constants
ROCK =0
PAPER =1
SCISSORS =2
hand_signal_names=["ROCK","PAPER","SCISSORS"] # define the names for each hand signal
# Read seed from input for random number generator
seed_value = int(input())
random.seed(seed_value)
# Step 1: Read player names and number of rounds
player1_name = input()
player2_name = input()
num_rounds = int(input())
# Make sure the number of rounds is valid
while num_rounds <1:
print("Rounds must be >0")
num_rounds = int(input())
# Output the player names and number of rounds
print(f"{player1_name} vs {player2_name} for {num_rounds} rounds")
# Step 4: Play the game for the specified number of rounds
player1_wins =0
player2_wins =0
# Loop through each round
for i in range(num_rounds):
# Generate a random hand signal for each player
player1_signal = random.randint(0,2)
player2_signal = random.randint(0,2)
# If both players make the same signal, it's a tie and we need to generate new signals
while player1_signal == player2_signal:
print("Tie")
player1_signal = random.randint(0,2)
player2_signal = random.randint(0,2)
# Determine the winner for this round and output a message
if player1_signal == ROCK and player2_signal == SCISSORS:
print(f"{player1_name} wins with rock")
player1_wins +=1
elif player1_signal == SCISSORS and player2_signal == PAPER:
print(f"{player1_name} wins with scissors")
player1_wins +=1
elif player1_signal == PAPER and player2_signal == ROCK:
print(f"{player1_name} wins with paper")
player1_wins +=1
else:
print(f"{player2_name} wins with {hand_signal_names[player2_signal]}")
player2_wins +=1
# Output the results
print(f"{player1_name} wins {player1_wins} and {player2_name} wins {player2_wins}")
IN PYTHON PLEASE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!