Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 3 Write a program that lets user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When

image text in transcribed

Problem 3 Write a program that lets user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don't display the computer's choice yet.) 1) The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. 2) The computer's choice is displayed 3) A winner is selected acceding to the following rules: - If one player chooses rock and other player chooses scissors, then rock wins. (Rock smashes scissors.) If one player chooses scissors and the other player choose paper, then scissors wins. (scissors cut paper.) - If one player chooses paper and the other play chooses rock, then paper wins. (Paper wraps rock.) If both players make the same choice, the game must be played again to determine the winner. Run your program several times. Below is an example output of how the program should function. Example output Enter 1 for rock, 2 for paper, 3 for scissors: 1 Computer chose rock You chose rock You made the same choice as the computer. Starting over Enter 1 for rock, 2 for paper, 3 for scissors: 2 Computer chose rock You chose paper You win the game. Enter 1 for rock, 2 for paper, 3 for scissors: 4 Computer chose paper You chose an invalid choice. No winner Enter 1 for rock, 2 for paper, 3 for scissors: 2 Computer chose rock You chose paper You win the game. Enter 1 for rock, 2 for paper, 3 for scissors: 3 Computer chose rock You chose scissors The computer wins the game. In [ ]: import random def rock_paper_scissors(): ### YOUR CODE HERE rock_paper_scissors()

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

Recommended Textbook for

Database 101

Authors: Guy Kawasaki

1st Edition

0938151525, 978-0938151524

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago