import hw3_util teams = hw3_util.read_fifa() def stats(index): Name = teams[index][0].ljust(20) Win = str(teams[index][2]).ljust(6) Draw = str(teams[index][3]).ljust(6) Lose = str(teams[index][4]).ljust(6) GF = str(teams[index][5]).ljust(6) GA = str(teams[index][6]).ljust(6) Pts = str(3 * int(Win) + int(Draw)).ljust(6) GD = str(int(GF) - int(GA)).ljust(6) return "%s%s%s%s%s%s%s%s" % (Name, Win, Draw, Lose, GF, GA, Pts, GD) team1 = int(raw_input('Team 1 id => ')) print team1 team2 = int(raw_input('Team 2 id => ')) print team2 print 'Team'.ljust(20) + 'Win'.ljust(6) + 'Draw'.ljust(6) + 'Lose'.ljust( 6) + 'GF'.ljust(6) + 'GA'.ljust(6) + 'Pts'.ljust(6) + 'GD'.ljust(6) print stats(team1) print stats(team2)
""" Program to compare any two FIFA teams. Author: Joe Noel (noelj) """ import hw3_util teams = hw3_util.read_fifa() #[group id, country, games, win, draw, lose, goals scored, goals against] def select_teams(): t1 = int(raw_input("First team index (0-31) ==> ")) print t1 t2 = int(raw_input("Second team index (0-31) ==> ")) print t2 return (t1,t2) def compare_teams( (t1,t2) ): team1 = teams[t1] team2 = teams[t2] Pts1 = 3 * team1[3] + team1[4] Pts2 = 3 * team2[3] + team2[4] Gdiff1 = team1[-2] - team1[-1] Gdiff2 = team2[-2] - team2[-1] GF1 = team1[-2] GF2 = team2[-2] if Pts1 > Pts2: print team1[1] + " is better than " + team2[1] elif Pts2 > Pts1: print team2[1] + " is better than " + team1[1] elif Pts1 == Pts2: