-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRockPaperSecissors.py
More file actions
73 lines (57 loc) · 1.52 KB
/
RockPaperSecissors.py
File metadata and controls
73 lines (57 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import random
def gamewin(comp,you):
if comp=='r':
if you=='p':
return True
elif you=='s':
return False
elif comp=='p':
if you=='s':
return True
elif you=='r':
return False
elif comp=='s':
if you=='r':
return True
elif you=='p':
return False
else:
return None
print("***WELCOME TO ROCK/PAPER/SCISSOR GAME***")
print()
matches=int(input("Enter matches you want to play in the series(odd number plz):"))
i=1
yourscore=0
computerscore=0
while(i<=matches):
print(f"Computer's turn:rock(r) paper(p) scissor(s)")
randcomp=random.randint(1,3)
if randcomp==1:
comp='r'
elif randcomp==2:
comp='p'
else:
comp='s'
print(f"Your turn:rock(r) paper(p) scissor(s)")
you=input()
print(f"Computer chose:{comp}")
print(f"You chose:{you}")
result=gamewin(comp,you)
if result==None:
yourscore=yourscore+0
computerscore=computerscore+0
elif result==True:
yourscore=yourscore+1
else :
computerscore=computerscore+1
i=i+1
print()
print("***RESULT TIME***")
print("YOUR SCORE:",yourscore)
print("COMPUTER SCORE:",computerscore)
if yourscore>computerscore:
print("YOU WIN!")
elif computerscore>yourscore:
print("COMPUTER WIN! BETTER LUCK NEXT TIME")
else:
print("NAIL BITING SERIES COMES TO AN END WITH A DRAW")