COMPSCI 105 S2 C- Assignment Two 6 of 7 Please write a program ResultTable.py, which reads such a file and (a) outputs all teams in sorted Please write a program ResultTable.py, which reads such a file and (e) ouspus all tams in sonted order and (b) outputs the teams for each conference in sorted order The sorting order is defined as follows: higher points means a higher rank, if the points are equal thema higher goal difference corresponds to a higher rank. If the points and goal difference are equal then a higher number of goals for the team corresponds to a higher rank. If two teams have exactly the same number of points, goal difference, and goals for the team, then the order of these two teams is undefined (i.e. either could be in front). The images on the next page show an example of an input file (left) and the corresponding (right) of your program. Example: In the input file (left) you can see Highlanders, 4, 52, 430, 286 52 points, 430 goals for and 286 goals against o goal difference is 144 Hurricanes, 4, 52, 458, 315 52 points, 458goals for and 314goals against-goal diference is 144 In the output (right) the Hurricanes are ranked higher because both teams have the same number of points and gryel difference, but the Hurricanes have scored more gools then the Highlandens.
ifile=open(\"input.txt\",\"r\")
team=[]
conference=[]
points=[]
goals=[]
goalsAgainst=[]
count=0;
for aline in ifile:
words=aline.split(\",\");
team.append(words[0])
conference.append(int(words[1]));
points.append(int(words[2]));
goals.append(int(words[3]));
goalsAgainst.append(int(words[4]));
count=count+1
goalDiff=[0]*count;
for x in range(0,count):
goalsDiff[x]=abs(goals[x]-goalsAgainst[x]);
print(\"Sorted Order\");
for x in range(0,count):
for y in range(0,count):
if(goalsDiff[x]>goalsDiff[y]):
s=team[x];
team[x]=team[y];
team[y]=s;
t=conference[x];
conference[x]=conference[y];
conference[y]=t;
t=points[x];
points[x]=points[y]
points[y]=t
t=goals[x]
goals[x]=goals[y];
goals[y]=t
t=goalsAgainst[x]
goalsAgainst[x]=goalsAgainst[y];
goalsAgainst[y]=t
print(\"Team Conference points goals goals Against\");
for x in range(0,count):
print(str(x+1)+\" \"+str(team[x])+\" \"+str(confernce[x])+\" \"+str(points[x])+\" \"+str(goals[x])+\" \"+str(goalsAgainst[x]));