Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Programming: Game – scissor, rock, paper. Create a program that plays thi

ID: 3864770 • Letter: P

Question

Python Programming:

Game – scissor, rock, paper. Create a program that plays this game:

• a scissor can cut a paper

• a rock can knock a scissor

• A paper can wrap a rock.

The program should randomly generate a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or2 and displays a message indicating whether the user or the computer wins, loses, or draws.

Example Runs:

Please enter a number: 0=scissor, 1=rock, 2=paper: 1

the computer chose scissor; you chose rock. You won. Please enter a number: 0=scissor, 1=rock, 2=paper: 2 The computer chose paper; you chose paper. It is a draw

NOTE: Let the user continue to play the game until they enter “Quit”

Explanation / Answer

from random import randint
while (1):
user = raw_input("Please Enter a number: 0=scissor, 1=rock, 2=paper:")
comp = (randint(0,2))
if user == '0':
if comp == 1:
print ("Computer choose rock you choose scissor. Computer wins")
elif comp == 2:
print ("Computer choose paper you choose scissor. You win")
else:
print("Computer choose scissor you choose scissor. Draw")
elif user == '1':
if comp == 1:
print ("Computer choose rock you choose rock. Draw")
elif comp == 2:
print ("Computer choose paper you choose rock. Computer wins")
else:
print ("Computer choose scissor you choose rock. You Win")
elif user == '2':
if comp == 1:
print ("Computer choose rock you choose paper. You Win")
elif comp == 2:
print ("Computer choose paper you choose paper. Draw")
else:
print ("Computer choose scissor you choose paper Computer wins")
elif user == 'quit':
break
else:
print ("Wrong choice.. Please enter correct Choice")