-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRock-Paper-Scissors.py
More file actions
executable file
·70 lines (54 loc) · 1.32 KB
/
Rock-Paper-Scissors.py
File metadata and controls
executable file
·70 lines (54 loc) · 1.32 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
#Aditya Nain
from random import randint
print("....rock....")
print("....paper....")
print("....scissors....")
p_score = 0
c_score = 0
while True:
#First to reach a score of 3 wins
if p_score==3 or c_score==3:
print(f"Player score : {p_score}")
print(f"Computer score: {c_score}\n")
if p_score>c_score:
print ("YOU WIN!!!\n")
elif p_score<c_score:
print ("YOU LOSE :(\n")
else:
print ("IT'S A DRAW\n")
x = input("Want to play again? y/n: ")
if x=="n":
print ("THANK YOU FOR PLAYING")
break
else:
p_score=0
c_score=0
else:
print(f"Player score : {p_score}")
print(f"Computer score: {c_score}\n")
p = input("Enter your choice: ")
#Computer's choice
c = randint(0,2)
if(c==0):
c = "rock"
elif(c==1):
c = "paper"
else:
c = "scissors"
if p_score!=3 and c_score!=3:
if(p==c):
print("Computer chose " + c +"\n")
p_score += 1
c_score += 1
elif(p=="rock" and c=="paper"):
print("Computer chose " + c +"\n")
c_score += 1
elif(p=="paper" and c=="scissors"):
print("Computer chose " + c +"\n")
c_score += 1
elif(p=="scissors" and c=="rock"):
print("Computer chose " + c +"\n")
c_score += 1
else:
print("Computer chose " + c +"\n")
p_score += 1