Skip to content

Commit e34a696

Browse files
Added Simple Python Game
Please add a label "hacktoberfest-accepted" on my pull request...
1 parent 7b3ae14 commit e34a696

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Silver_Project_RockPaperSciss.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import random
2+
3+
4+
def getUserInput():
5+
player = 'blank'
6+
while player.lower() != 'r' and player.lower() != 'p' and player.lower() != 's':
7+
player = input("\n\nEnter your valid choice from R,P or S: ").lower()
8+
return player
9+
10+
11+
def getSystemInput():
12+
lst = ['r', 'p', 's']
13+
bot = random.choice(lst)
14+
return bot
15+
16+
17+
def checkWinner(player, bot):
18+
if player == bot: # If both player and bot choose the same
19+
return 'draw'
20+
elif player == 'r' and bot == 'p':
21+
return 'bot'
22+
elif player == 'r' and bot == 's':
23+
return 'player'
24+
elif player == 'p' and bot == 'r':
25+
return 'player'
26+
elif player == 'p' and bot == 's':
27+
return 'bot'
28+
elif player == 's' and bot == 'r':
29+
return 'bot'
30+
elif player == 's' and bot == 'p':
31+
return 'player'
32+
33+
34+
def rockPaperScissor():
35+
resume = 'y'
36+
player_score = 0
37+
bot_score = 0
38+
while resume.lower() == 'y':
39+
ply = getUserInput()
40+
bt = getSystemInput()
41+
print('Bot Entered - ', bt)
42+
print('You Entered - ', ply)
43+
winner = checkWinner(ply, bt)
44+
print('Winner is - ', winner)
45+
if winner == 'player':
46+
player_score += 1
47+
elif winner == 'bot':
48+
bot_score += 1
49+
print("\n\n------ScoreCard------")
50+
print("Player:", player_score)
51+
print("Bot:", bot_score)
52+
resume = input("\n\nDO YOU WANT TO CONTINUE THE GAME!? Press y : ")
53+
54+
55+
rockPaperScissor()

0 commit comments

Comments
 (0)