Skip to content

Commit 68be632

Browse files
Merge pull request raviprakashdev#20 from Alleny244/master
Added Python code for the game rock paper scissors
2 parents 9e7bd10 + 428df93 commit 68be632

1 file changed

Lines changed: 98 additions & 0 deletions

File tree

rock.py

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
from random import randint
2+
gameplay=['Rock','Paper','scissors']
3+
n=3
4+
Computer=gameplay[randint(0,2)]
5+
Player=False
6+
YourScore=0
7+
ComputerScore=0
8+
i=0
9+
while i<n:
10+
11+
while Player==False:
12+
13+
choice=input('choose any of the three Rock,Paper or scissors\n')
14+
if choice==Computer:
15+
YourScore=0
16+
ComputerScore=0
17+
print('Computer =',Computer)
18+
19+
print('woah!,Tie.')
20+
elif choice=='Rock':
21+
22+
if Computer=='Paper':
23+
print('Computer =',Computer)
24+
25+
print('you lose!',Computer,
26+
'covered the',choice)
27+
ComputerScore=ComputerScore+1
28+
else:
29+
print('Computer =',Computer)
30+
31+
print('woah! you win',choice,'damaged the',Computer)
32+
YourScore=YourScore+1
33+
34+
elif choice=='Paper':
35+
36+
if Computer=='Rock':
37+
print('Computer =',Computer)
38+
39+
print('woah! you win',choice, 'covered the' ,Computer)
40+
YourScore=YourScore+1
41+
42+
43+
else:
44+
print('Computer =',Computer)
45+
46+
print('you lose!,',Computer, 'cut the' ,choice)
47+
ComputerScore=ComputerScore+1
48+
49+
50+
elif choice=='scissors':
51+
52+
if Computer=='Rock':
53+
print('Computer =',Computer)
54+
55+
print(' you loose,',Computer, 'damaged the', choice)
56+
ComputerScore=ComputerScore+1
57+
else:
58+
print('Computer =',Computer)
59+
60+
print('you win!',choice, 'cut the', Computer)
61+
YourScore=YourScore+1
62+
elif choice=='Stop':
63+
break;
64+
65+
66+
else :
67+
68+
print('enter a valid choice')
69+
Player=True
70+
71+
72+
73+
i=i+1
74+
75+
76+
77+
78+
print('YourScore=',YourScore)
79+
print('ComputerScore=',ComputerScore)
80+
if YourScore>ComputerScore:
81+
print('YOU WIN')
82+
elif YourScore<ComputerScore:
83+
84+
print('YOU LOOSE')
85+
else:
86+
print('TIE')
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+

0 commit comments

Comments
 (0)