Skip to content

Instantly share code, notes, and snippets.

@janaki-sasidhar
Created July 15, 2021 04:57
Show Gist options
  • Save janaki-sasidhar/e63a93c7c81195e06a47f5ac4756f080 to your computer and use it in GitHub Desktop.
Save janaki-sasidhar/e63a93c7c81195e06a47f5ac4756f080 to your computer and use it in GitHub Desktop.
class Player:
def __init__(self,matches: int ,goals:int , rating : int , name :str):
self.matches = matches
self.rating = rating
self.goals = goals
self.name = name
class FootballLeague:
def __init__(self,leagueName:str, List):
self.leagueName = leagueName
self.List = List
def findMaximumPlayerByRating(self):
sorted_list = sorted(self.List , key=lambda player: player.rating)
if sorted_list:
return sorted_list[-1]
else:
return None
def sortPlayerByGoals(self):
sorted_list = sorted(self.List , key=lambda player : player.goals)
if sorted_list:
return sorted_list
else:
return None
if __name__=='__main__':
number=int(input())
playerlist=[]
for _ in range(number):
matches=int(input())
goals=int(input())
rating=int(input())
name=input()
player_object = Player(matches,goals,rating , name)
playerlist.append(player_object)
league_object :FootballLeague = FootballLeague('myleague' , playerlist)
min_by_rating_result = league_object.findMaximumPlayerByRating()
sorted_list = league_object.sortPlayerByGoals()
print(float(min_by_rating_result.matches))
print(int(min_by_rating_result.goals))
print(str(min_by_rating_result.rating))
print(str(min_by_rating_result.name))
for list_item in sorted_list:
print(list_item.goals)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment