Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1.0 Loops Westerm New A England the 105 University The wishes to award a player

ID: 3578403 • Letter: 1

Question

1.0 Loops Westerm New A England the 105 University The wishes to award a player based upon the highest average for year. the league keeps records the players in an array. Write the function (named FindB est) highest takes one teams and value the (the team the array (STATS) and 4 players matrix and the player number of per team might look like: a league with 3 Stats For Players 1 .123 .231 .301 .231 2 210 167 327 301 3 I. 275 299 267 .212 The function FindBest would return player 3 the and team 2 for ree team four players per team shown above. There are no load statements in your solution, the data is already e array STATS. You must however declare any variables you use. Assume a league with 6 teams (rows) and 9 players per team (colur credit will be given for a hard coded solution to the example ve)

Explanation / Answer

#function in python

def findBest( matrix ):
  
player = 0;
team = 0;
best = matrix[0][0];

rows = len(matrix)
cols = len(matrix[0])
  
for i in range(rows):
for j in range(cols):
  
if matrix[i][j] > best :
best = matrix[i][j]
team = i
player = j
  
return (team+1,player+1)

#call of function..

m = int(input('number of Team, m = '))
n = int(input('number of Player, n = '))
matrix = [[0 for i in range(n)] for j in range(m)];


for i in range (0,m):
for j in range (0,n):
print("Enter your Score for team = ",i+1," and player = ",j+1," : ")
score = float(input())
matrix[i][j] = score;
  


team,player = findBest(matrix);
print ("Best player = ",player," from Team = ",team)
print ("Best score is : ",matrix[team-1][player-1])