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

Instructions: Write a python program that allows users to play the popular rock-

ID: 3750464 • Letter: I

Question

Instructions: Write a python program that allows users to play the popular rock-paper-scissor game against the computer. Basic game rule: a scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.


First, you need to design the program. In a Word or text document, please define either the pseudo code or the flowchart (maybe messy) for this problem.


Next, write the python code based on your design. You can choose the names of variables, how to represent the choices for rock, paper, and scissor, and the exact format of the output, etc. However, make sure to include both the computer and the user’s choice in each of your print statement so you can verify that you implemented the game rule correctly.


Fix any syntax errors and test your code if you can.


Note: this program does not limit the user or computer’s choices, so you need to process all the possible scenarios of the game. Pay extra attention to indentation.

Please paste all code in chegg! Also post screenshots of the code in python and the code running.

Explanation / Answer

ANS:

(OR)


import random #to use random funtion
a=random.randint(0,2); #generates random numbers between 0 and 2 including 2 also
x=input("Enter number 0,1 or 2 ") #prompting user to enter the number
list = ["scissor","rock","paper"] #creating a list
if(a==x): #comparig computer generated number with our choice
print "The compute is"+ list[a]+ "."+"You are" + list[x] +"too"+"It is draw" #list[a] means print correspinding string from list
elif(a==0 and x==1):
print "The computer is"+" "+list[a]+" "+"you are"+" "+list[x]+"You won"
elif(a==0 and x==2):
print "The computer is"+" "+list[a]+" "+"you are"+" "+list[x]+"Computer won"
elif(a==1 and x==0):
print "The computer is"+" "+list[a]+" "+"you are"+" "+list[x]+"Computer won"
elif(a==1 and x==2):
print "The computer is"+" "+list[a]+" "+"you are"+" "+list[x]+"You won"
elif(a==2 and x==0):
print "The computer is"+" "+list[a]+" "+"you are"+" "+list[x]+"computer won"
elif(a==2 and x==1):
print "The computer is"+" "+list[a]+" "+"you are"+" "+list[x]+"Your won"