forked from larymak/Python-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rock-Paper Scissor.py
108 lines (67 loc) · 1.83 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python
# coding: utf-8
# In[1]:
def takePlayerInput():
player = "blank"
while not (player.lower() == "r" or player.lower() == "p" or player.lower() == "s"):
player = input("Please Enter your input out of - R | P | S = ")
return player.lower()
# In[2]:
takePlayerInput()
# In[3]:
import random
def getBotInput():
lst = ["r", "s", "p"]
return random.choice(lst)
# In[4]:
getBotInput()
# In[5]:
def checkWinner(player, bot):
if player == "r" and bot == "r":
return "Draw"
elif player == "r" and bot == "p":
return "Bot"
elif player == "r" and bot == "s":
return "Player"
elif player == "p" and bot == "p":
return "Draw"
elif player == "p" and bot == "r":
return "Player"
elif player == "p" and bot == "s":
return "Bot"
elif player == "s" and bot == "s":
return "Draw"
elif player == "s" and bot == "p":
return "Player"
elif player == "s" and bot == "r":
return "Bot"
else:
return "DRAW"
# In[6]:
checkWinner("s","p")
# In[7]:
def rockPaperScissor():
endTheGame = "n"
player_score = 0
bot_score = 0
while endTheGame.lower() != "y":
ply = takePlayerInput()
bt = getBotInput()
print("Bot Entered -", bt)
winner = checkWinner(player = ply, bot = bt)
print("Winner is - ", winner)
if winner == "Player":
player_score += 2
elif winner == "Bot":
bot_score += 2
else :
player_score += 1
bot_score += 1
print("-----Score Board-----")
print("-----Player-----", player_score)
print("-----Bot-----", bot_score)
print(" ")
endTheGame = input("You want to end Y/N - ")
# In[8]:
rockPaperScissor()
# In[ ]: