-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrock paper scissor.py
67 lines (58 loc) · 1.56 KB
/
rock paper scissor.py
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
# rock paper scissor
import random
comp_score = user_score = 0
def comp_turn(a):
x = random.randint(1, 3)
print(" ", a, "<-->", x, " ")
result(a, x)
def result(a, x):
global comp_score, user_score
if a == 1:
if x == 2:
print("computer won")
comp_score += 1
elif x == 3:
print("you won")
user_score += 1
else:
print("tied")
elif a == 2:
if x == 1:
print("you won")
user_score += 1
elif x == 3:
print("computer won")
comp_score += 1
else:
print("tied")
elif a == 3:
if x == 1:
print("computer won")
comp_score += 1
elif x == 2:
print("you won")
user_score += 1
else:
print("tied")
else:
print("enter the correct choice")
main()
def main():
print("1- stone; ")
print("2- paper; ")
print("3- scissors; ")
a = int(input("enter your choice"))
comp_turn(a)
ch = input("one more play? (y/n) ")
if ch == "y":
main()
else:
print("****** end Scores ******")
print("Your Score: ", user_score, "\t Computer Score: ", comp_score)
if user_score > comp_score:
print("Congratulations ! You are the overall winner")
elif comp_score > user_score:
print("Better Luck Next time ! Computer is the overall winner")
else:
print("Played well ! Both you and computer tied")
main()