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

(Game: scissor, rock, paper) Write a program that plays the popular scissor-rock

ID: 3585952 • Letter: #

Question

(Game: scissor, rock, paper) Write a program that plays the popular scissor-rock- paper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws. Here are sample runs: *4.17 scissor (0), rock (1), paper (2): 1 Enter The computer is scissor. You are rock. You won.

Explanation / Answer

from random import randint c=['scissor','rock','paper'] choice=int(input('scissor (0), rock(1), paper(2):')) comp=randint(0,2) w=0 l=0 d=0 if comp==0 and choice==1: w=1 elif comp==0 and choice==2: l=1 elif comp==1 and choice==0: l=1 elif comp==1 and choice==2: w=1 elif comp==2 and choice==0: w=1 elif comp==2 and choice==1: l=1 elif comp==choice: d=1 if w==1: print('The computer is '+c[comp]+'.You are '+c[choice],'.You won') if l==1: print('The computer is '+c[comp]+'.You are '+c[choice]+'.You lose') if d==1: print('The computer is '+c[comp]+'.You are '+c[choice]+'.You drew')