5.13 LAB*: Program: Rock paper scissors 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 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 Sample output is: Rounds must be > 0 Rounds must be > 0 Anna vs Bert for 4 rounds. Step 2 . 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: 12 Anna Bert 1 Sample output is: Anna vs Bert for 1 rounds. Tie Tie

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How to solve this question using python?

Step 3
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:
55
Anna
Bert
1
Sample output is:
Anna vs Bert for 1 rounds
Tie
Bert wins with rock
Step 4. 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
Bert wins with paper
Anna wins with scissors
Tie
Anna wins with scissors
Anna wins 2 and Bert wins 1
Transcribed Image Text:Step 3 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: 55 Anna Bert 1 Sample output is: Anna vs Bert for 1 rounds Tie Bert wins with rock Step 4. 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 Bert wins with paper Anna wins with scissors Tie Anna wins with scissors Anna wins 2 and Bert wins 1
5.13 LAB*: Program: Rock paper scissors
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 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
-4
4
Sample output is:
Rounds must be > 0
Rounds must be > 0
Anna vs Bert for 4 rounds
Step 2
. 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:
12
Anna
Bert
1
Sample output is:
Anna vs Bert for 1 rounds.
Tie
Tie
Transcribed Image Text:5.13 LAB*: Program: Rock paper scissors 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 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 -4 4 Sample output is: Rounds must be > 0 Rounds must be > 0 Anna vs Bert for 4 rounds Step 2 . 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: 12 Anna Bert 1 Sample output is: Anna vs Bert for 1 rounds. Tie Tie
Expert Solution
Step 1

Algorithm:

  1. Import the random module
  2. Define constants ROCK, PAPER, and SCISSORS and assign them integer values of 0, 1, and 2 respectively.
  3. Read a seed from the user and use it to seed the random number generator.
  4. Read the names of two players from the user.
  5. Initialize the number of rounds to 0, the count of rounds to 0, and the count of wins for both players to 0.
  6. Enter a loop that continues until the number of rounds is greater than or equal to 1: a. Read the number of rounds from the user. b. If the number of rounds is greater than or equal to 1, break out of the loop. c. If the number of rounds is less than 1, print an error message.
  7. Display the names of both players and the number of rounds they will play.
  8. Enter a loop that continues until the count of rounds is equal to the number of rounds: a. Generate two random integers between 0 and 2 (inclusive) for each player. b. If both players have the same value, print "Tie". c. If player 1 plays ROCK: i. If player 2 plays SCISSORS, print player 1 wins with rock and increment player 1's win count. ii. If player 2 plays PAPER, print player 2 wins with paper and increment player 2's win count. d. If player 1 plays PAPER: i. If player 2 plays ROCK, print player 1 wins with paper and increment player 1's win count. ii. If player 2 plays SCISSORS, print player 2 wins with scissors and increment player 2's win count. e. If player 1 plays SCISSORS: i. If player 2 plays PAPER, print player 1 wins with scissors and increment player 1's win count. ii. If player 2 plays ROCK, print player 2 wins with rock and increment player 2's win count. f. Increment the count of rounds.
  9. Print the count of wins for both players.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Types of Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education