Question: Python Computer Programming (Rock, paper, scissors game) Write a program that lets the user play rock, paper, scissors against the computer. Here is how it
Python Computer Programming
(Rock, paper, scissors game) Write a program that lets the user play rock, paper, scissors against the computer. Here is how it should work: 1. A random number between 1 and 3 should be generated at the start of the game. If that number is 1, then the computer will play "rock", if it is 2, then the computer will play "paper", and if it is 3 then the computer will play "scissors" (but do not display this choice to the user). 3. The computer's choice is shown after the user enters their choice. 4. The winner is selected by the following rules:
- if one chooses rock and the other scissors, the player choosing rock wins
- if one chooses scissors and the other chooses paper, the play choosing scissors wins
- if one chooses paper and the other chooses rock, the player choosing paper wins
- if both players choose the same, then the game is a die and must be played again
5. The entire gameplay steps 1 through 3 should be built into a function named
play_game()
. Based on step 4, the function should either print the winner and return a 1 OR it should print "There is a tie" and return a 0. Returning a zero should cause a loop running the game function to be run again until a 1 is returned. (hint: something like
while gamereturn!=1: gamereturn=play_game()
is what you want to do here)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
