Answer:
Check the explanation
Step-by-step explanation:
from random import randint
def startGame(round,p1Name,p2Name,p1Wins,p2Wins):
print("\\Playing round", round ,"of Beat That...")
print(p1Name,"rolls")
p1 = rollDice(p1Name)
print(p2Name,"rolls")
p2 = rollDice(p2Name)
if p1 > p2:
print(p1Name,"Wins this Round!")
p1Wins += 1
elif p2 > p1:
print(p2Name,"Wins this Round!")
p2Wins +=1
else:
print("The Players Tie this Round")
return p1Wins,p2Wins
def maxNumber(num):
a = []
for i in range(len(num)):
a.append(max(num))
num.remove(max(num))
maxNum = ''.join(map(str,a))
return maxNum
def getDiceRollValue(numOfDice):
num = []
for i in range(numOfDice):
a = randint(1, 6)
num.append(a)
return num
def rollDice(playerName):
rollValue = getDiceRollValue(numOfDice)
print(rollValue)
maxNumOutofRoll = maxNumber(rollValue)
print(playerName, "chooses",maxNumOutofRoll)
return maxNumOutofRoll
def winner(p1Name,p2Name,p1Wins,p2Wins):
print("Game Score:",p1Name,"has won",p1Wins,"rounds.",p2Name,"has won",p2Wins,"rounds.")
if p1Wins > p2Wins:
print(p1Name,"Wins This Game!")
elif p2Wins > p1Wins:
print(p2Name,"Wins This Game!")
else:
print("The Players Tie the Game")
numOfDice = 2
numOfRounds = 5
p1Name = "Player 1"
p2Name = "Player 2"
p1Wins = 0
p2Wins = 0
for i in range(1,numOfRounds+1):
p1Wins,p2Wins = startGame(i,p1Name,p2Name,p1Wins,p2Wins)
winner(p1Name,p2Name,p1Wins,p2Wins)