forked from shikaruki/Hactoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game_rock_paper.py
41 lines (36 loc) · 1.01 KB
/
Game_rock_paper.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
import random
#initiating the values
userWins=0
compWins=0
draw=0
#defining the while loop
while userWins<3 and compWins<3:
#keep taking the inputs from the user
user=eval(input("scissor(0), rock(1), paper(2):"))
comp=random.randint(0,2)
#Conversion of the number into a string
if user==0:
u="scissor"
elif user==1:
u="rock"
else:
u="paper"
#Conversions for the computer
if comp==0:
c="scissor"
elif user==1:
c="rock"
else:
c="paper"
#choosing the winners
if user==(comp+1)%3:
print("The computer is " +c+" You are "+u+". You won! Congrats!.\n")
userWins+=1
elif user==(comp-1)%3:
print("The computer is " +c+" You are "+u+". You lose... Computer won!.\n")
compWins+=1
else:
print("The match has drawed... Both you and the computer are "+u+".Better try again.\n")
draw+=1
totalGames=userWins+compWins+draw
print("Game Ended..... \n You won ",userWins," times out of",totalGames)