Question: import random ROCK = 0 PAPER = 1 SCISSORS = 2 # Read random seed to support testing ( do not alter ) and starting

import random ROCK =0 PAPER =1 SCISSORS =2 # Read random seed to support testing (do not alter) and starting credits seed = int(input()) # Set the seed for random random.seed(int(seed)) # Step 1: Read player names and number of rounds player1= input() player2= input() rounds = int(input()) # Validate rounds input while rounds <=0: print("Rounds must be >0") rounds = int(input()) # Output player names and number of rounds print(f"{player1} vs {player2} for {rounds} rounds") # Initialize win counters player1_wins =0 player2_wins =0 # Step 2: Start the game for the specified rounds for _ in range(rounds): player1_choice = random.randint(0,2) # 0: Rock, 1: Paper, 2: Scissors player2_choice = random.randint(0,2) if player1_choice == player2_choice: print("Tie") else: if player1_choice == ROCK: if player2_choice == SCISSORS: print(f"{player1} wins with rock") player1_wins +=1 else: print(f"{player2} wins with paper") player2_wins +=1 elif player1_choice == PAPER: if player2_choice == ROCK: print(f"{player1} wins with paper") player1_wins +=1 else: print(f"{player2} wins with scissors") player2_wins +=1 elif player1_choice == SCISSORS: if player2_choice == PAPER: print(f"{player1} wins with scissors") player1_wins +=1 else: print(f"{player2} wins with rock") player2_wins +=1 # Output total wins print(f"{player1} wins {player1_wins} and {player2} wins {player2_wins}") Please fix the above code so it adheres to the following directions: Program Specifications Write a program to play an automated game of Rock, Paper, Scissors. Two players make one of three hand signals at the same time. Hand signals represent a rock, a piece of paper, or a pair of scissors. Each combination results in a win for one of the players. Rock crushes scissors, paper covers rock, and scissors cut paper. A tie occurs if both players make the same signal. Use a random number generator of 0,1, or 2 to represent the three signals. Note: this program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. Step 0. Read starter template and do not change the provided code. Variables are defined for ROCK, PAPER, and SCISSORS. A seed is read from input to initialize the random number generator. This supports automated testing and creates predictable results that would otherwise be random. Step 1(2 pts). Read two player names from input (str). Read number of rounds from input. Continue reading number of rounds if value is below one and provide an error message. Output player names and number of rounds. Submit for grading to confirm 2 tests pass. Ex: If input is: 3 Anna Bert -3-44 Sample output is: Rounds must be >0 Rounds must be >0 Anna vs Bert for 4 rounds Step 2(2 pts). Use random.randint(0,2) to generate random values (0-2) for player 1 followed by player 2. Continue to generate random values for both players until both values do not match. Output "Tie" when the values match. Submit for grading to confirm 3 tests pass. Ex: If input is: 22 Anna Bert 1 Sample output is: Anna vs Bert for 1 rounds Tie Tie Step 3(3 pts). Identify winner for this round and output a message. Rock crushes scissors, scissors cut paper, and paper covers rock. Submit for grading to confirm 6 tests pass. Ex: If input is: 15 Anna Bert 1 Sample output is: Anna vs Bert for 1 rounds Tie Bert wins with rock Step 4(3 pts). Add a loop to repeat steps 2 and 3 for the number of rounds. Output total wins for each player after all rounds are complete. Submit for grading to confirm all tests pass. Ex: If input is: 82 Anna Bert 3 Sample output is: Anna vs Bert for 3 rounds Tie Bert wins with rock Tie Bert wins with rock Tie Anna wins with paper Anna wins 1 and Bert wins 2

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 Programming Questions!