This project is a Python-based implementation of the classic Rock-Paper-Scissors game. It is designed for two players and allows for multiple rounds of play. The game determines the winner of each round and ultimately declares an overall winner or a tie.
No additional installation is required if Python is already installed. This game can be run in any Python environment.
Final Outcome: After all rounds, determine and display the overall winner.
def tie():
global p1c, p2c
if p1 == p2:
print("Match Tie")
p1c += 1
p2c += 1
def p1Wins():
global p1c
if p1 == 'rock' and p2 == 'scissor':
print("Player 1 wins")
p1c += 1
elif p1 == 'paper' and p2 == 'rock' :
print("Player 1 wins")
p1c += 1
elif p1 == 'scissor' and p2 == 'paper' :
print("Player 1 wins")
p1c += 1
def p2Wins():
global p2c
if p2 == 'rock' and p1 == 'scissor':
print("Player 2 wins")
p2c += 1
elif p2 == 'paper' and p1 == 'rock' :
print("Player 2 wins")
p2c += 1
elif p2 == 'scissor' and p1 == 'paper' :
print("Player 2 wins")
p2c += 1
def whoWins():
global p1c, p2c
if p1c == p2c : print("Final Match Tie")
elif p1c > p2c : print("Finally Player 1 wins")
elif p1c < p2c : print("Finally Player 2 wins")
p1c = 0
p2c = 0
signs = ['rock', 'paper', 'scissor']
for i in range(int(input("How many times you want to play: "))):
p1 = input("Player 1 - Choose Rock/Paper/Scissor : ").lower()
p2 = input("Player 2 -Choose Rock/Paper/Scissor : ").lower()
if p1 in signs and p2 in signs:
tie()
p1Wins()
p2Wins()
else: print('Invalid input')
whoWins()
def tie():
global p1c, p2c
if p1 == p2:
print("Match Tie")
p1c += 1
p2c += 1
def p1Wins():
global p1c
if p1 == 'rock' and p2 == 'scissor':
print("Player 1 wins")
p1c += 1
elif p1 == 'paper' and p2 == 'rock' :
print("Player 1 wins")
p1c += 1
elif p1 == 'scissor' and p2 == 'paper' :
print("Player 1 wins")
p1c += 1
def p2Wins():
global p2c
if p2 == 'rock' and p1 == 'scissor':
print("Player 2 wins")
p2c += 1
elif p2 == 'paper' and p1 == 'rock' :
print("Player 2 wins")
p2c += 1
elif p2 == 'scissor' and p1 == 'paper' :
print("Player 2 wins")
p2c += 1
def whoWins():
global p1c, p2c
if p1c == p2c : print("Final Match Tie")
elif p1c > p2c : print("Finally Player 1 wins")
elif p1c < p2c : print("Finally Player 2 wins")
p1c = 0
p2c = 0
signs = ['rock', 'paper', 'scissor']
for i in range(int(input("How many times you want to play: "))):
p1 = input("Player 1 - Choose Rock/Paper/Scissor : ").lower()
p2 = input("Player 2 -Choose Rock/Paper/Scissor : ").lower()
if p1 in signs and p2 in signs:
tie()
p1Wins()
p2Wins()
else: print('Invalid input')
whoWins()
Initialize p1c, p2c to 0
Define signs as ['rock', 'paper', 'scissor']
For each round (user-defined number):
Get Player 1's choice
Get Player 2's choice
If both choices are valid:
Call tie()
Call p1Wins()
Call p2Wins()
Else:
Print 'Invalid input'
Call whoWins() to determine the final winner
Initialize p1c, p2c to 0
Define signs as ['rock', 'paper', 'scissor']
For each round (user-defined number):
Get Player 1's choice
Get Player 2's choice
If both choices are valid:
Call tie()
Call p1Wins()
Call p2Wins()
Else:
Print 'Invalid input'
Call whoWins() to determine the final winner
Global Variables: p1c, p2c for keeping score, signs for valid choices.
Logic: Compares p1c and p2c to declare the final winner or a tie.
Office:- 660, Sector 14A, Vasundhara, Ghaziabad, Uttar Pradesh - 201012, India