-
Notifications
You must be signed in to change notification settings - Fork 0
/
RockPaperScissor_1.py
86 lines (61 loc) · 1.78 KB
/
RockPaperScissor_1.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
77
78
79
80
81
82
#!/usr/bin/env python
# coding: utf-8
# In[42]:
def toGetInputFromUser():
player="blank"
while not(player.lower()=="r" or player.lower()=="p" or player.lower()=="s"):
player=input("enter your input out of R | P | S: ")
return player
# In[51]:
import random
def toGetInputFromBot():
lst=["r","p","s"]
bot=random.choice(lst)
return bot
# In[57]:
def toCheckWinner(player,bot):
if(player=="r" and (bot=="p" or bot=="s")):
if(bot=="p"):
return "player"
else:
return "bot"
elif(player=="p" and (bot=="r" or bot=="s")):
if(bot=="p"):
return "player"
else:
return "bot"
elif(player=="s" and (bot=="p" or bot=="r")):
if(bot=="p"):
return "player"
else:
return "bot"
elif(player==bot):
return "draw"
# In[90]:
def rps():
playerScore=0
botScore=0
quite="n"
while(quite !="y"):
player=toGetInputFromUser()
print("\nThe player choose:",player)
bot=toGetInputFromBot()
print("\nThe bot choose : ",bot)
winner=toCheckWinner(player,bot)
print("\nthe winner is: ",winner,"\n\n")
if(winner=="player"):
playerScore+=2
elif(winner=="bot"):
botScore+=2
else:
playerScore+=1
botScore+=1
print("Score Board".rjust(20," "))
print("_____________________________________________")
print("\nPlayer's score---------> \t",playerScore)
print("\nBot's Score------------>\t",botScore)
print("_____________________________________________")
quite=input("\nIf you want quite press y otherwise press n\n")
print("XXX".center(50,"_"))
rps()
# In[ ]: