forked from coder2hacker/Explore-open-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ROCK_PAPER_SCISSORS.py
78 lines (57 loc) · 2.29 KB
/
ROCK_PAPER_SCISSORS.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
68
69
70
71
72
73
74
75
76
import random
print("ROCK\nPAPER\nSCISSORS")
print("-----------------------------\n")
print("r for rock\np for paper\ns for scissors\n--------\n")
lst=['r','p','s']
chance_taken=0
comp_point=0
player_point=0
remain_chance=10
while(remain_chance>chance_taken):
ip=input("enter your selection: ")
c=random.choice(lst)
if c==ip:
print("Both tie so 0 point to both")
elif c=='r' and ip=='p':
print(f"You entered {ip} and computer entered {c}")
print("You wins 1 point")
player_point=player_point+1
print(f"Your score:{player_point}\t computer score:{comp_point}")
elif c=='r' and ip=='s':
print(f"You entered {ip} and computer entered {c}")
print("Computer wins 1 point")
comp_point=comp_point+1
print(f"Your score:{player_point}\t computer score:{comp_point}")
elif c=='p' and ip=='r':
print(f"You entered {ip} and computer entered {c}")
print("Computer wins 1 point")
comp_point=comp_point+1
print(f"Your score:{player_point}\t computer score:{comp_point}")
elif c=='p' and ip=='s':
print(f"You entered {ip} and computer entered {c}")
print("You wins 1 point")
player_point=player_point+1
print(f"Your score:{player_point}\t computer score:{comp_point}")
elif c == 's' and ip == 'r':
print(f"You entered {ip} and computer entered {c}")
print("You wins 1 point")
player_point = player_point + 1
print(f"Your score:{player_point}\t computer score:{comp_point}")
elif c=='s' and ip=='p':
print(f"You entered {ip} and computer entered {c}")
print("Computer wins 1 point")
comp_point=comp_point+1
print(f"Your score:{player_point}\t computer score:{comp_point}")
else:
print("enter valid choice ")
continue
chance_taken=chance_taken+1
print(f"you have consumed:{chance_taken} chance \t remaing chances :{remain_chance-chance_taken}")
print("-----------------------------\n")
if(comp_point==player_point):
print("Gameover\nThis is a tie")
elif comp_point>player_point:
print("Game over\nSorry..you lose..play again")
elif comp_point<player_point:
print("Game over\nHurray...You win")
print(f"Your score :{player_point}\t Computer score :{comp_point}")