Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write an algorithm for a Rock Paper Scissors game. The user should enter either rock, or paper, or scissors while the computer makes its choice

Write an algorithm for a Rock Paper Scissors game. The user should enter either rock, or paper, or scissors while the computer makes its choice randomly. The two choices are then compared with the user being told whether they won, lost, or tied. For this game Rock beats Scissors, which beats Paper, which beats Rock. Include your algorithm as comments in your submission.

See here for an example of what an algorithm should look like.

If you submit python code instead on an algorithm you will not receive points for this question.

python for language

image text in transcribed

Algorithm Example For the following task: Use the random module to write a number guessing game. The number the computer chooses should change each time you run the program. Repeatedly ask the user for a number. If the number is different from the computer's let the user know if they guessed too high or too low. If the number matches the computer's, the user wins. Keep track of the number of tries it takes the user to guess it. An appropriate algorithm might be: mport the random module Display a welcome message to the user Choose a random number between1 and 100 Get a guess from the user Set a number of tries to 0 As long as their guess isn't the number Check if guess is lower than computer If so, print a lower message Otherwise, is it higher? fso, print a higher message Get another guess Increment the tries Repeat When they guess the computer's number, display the number and their tries count Notice that each line in the algorithm corresponds to roughly a line of code in Python, but there is no coding itself in the algorithm. Rather the algorithm lays out what needs to happen step by step to achieve the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

5. If yes, then why?

Answered: 1 week ago

Question

6. How would you design your ideal position?

Answered: 1 week ago