sir sand sir sand - 7 months ago 17
Python Question

Python 12 teams 8 bowlers each

Assignment Description: There are 8 members per team and 12 teams in the league. Each bowler needs their score (between 0 and 300) to be entered. The winning team is found by determining the highest average score. Output the team’s name and average that wins the competition. NO arrays used.

For this problem, how would one nest if statements so it continues down if the team number is below 12, then continue to check if the member number is below 8?

def inputScore():totalScore = 0for team in range (1,13):
team = int(input("Team number: "))
while (team<0 or team>13):
team = int(input("Invalid input. Enter team number 1-12: "))
bowler = int(input("Enter bowler number: "))
while (bowler<0 or bowler>8):
bowler = int(input("Invalid input. Enter bowler number 1-8 "))
score = int(input("Enter score: "))
while (score<0 or score>300):
score = int(input("Invalid input. Enter score 0-300: "))
total=(bowler*score)
totalScore=totalScore + total
return totalScoretotalAvg=inputScore()
avg=totalAvg/8


print ("The highest score for teams are: ", avg)

Here's what I have now, I know there's stuff wrong with it. I'm not quite sure how to fix it. Any help?

Answer

You are missing a closing parenthesis score = int(input("Enter bowler's score: "))

EDIT: Partial answer:

def getTeamScore(teamNumber):
    print("Scores for team " + str(teamNumber))
    score1 = int(input("Score for player 1: "))
    score2 = int(input("Score for player 2: "))
    return (score1 + score2) / 2 #Remember parenthesis here


bestScore = -1
bestTeam = 0

for teamNumber in range(1, 3):
    teamScore = getTeamScore(teamNumber)
    if (teamScore > bestScore):
        bestScore = teamScore
        bestTeam = teamNumber

print("Best team: " + str(bestTeam) + " with score: " + str(bestScore))
Comments