0% found this document useful (0 votes)
216 views2 pages

Mock SBQ 1 Solution

The document defines a Team class with attributes (owner, value, ID, name) and a League class with attributes (leagueName, teamList). The League class has methods to find the team with the minimum ID and sort teams by ID. The code takes user input to create a list of teams, initializes a League object, and calls the League methods to output results.

Uploaded by

Technical Akash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
216 views2 pages

Mock SBQ 1 Solution

The document defines a Team class with attributes (owner, value, ID, name) and a League class with attributes (leagueName, teamList). The League class has methods to find the team with the minimum ID and sort teams by ID. The code takes user input to create a list of teams, initializes a League object, and calls the League methods to output results.

Uploaded by

Technical Akash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Python

--------------------------------------------------

class Team:
def __init__(self,owner,value,ID,name):
self.owner=owner
self.value=value
self.ID=ID
self.name=name

class League:
def __init__(self,leagueName,teamList):
self.leagueName=leagueName
self.teamList=teamList

def findMininumTeamByID(self):
min_obj=min(self.teamList,key=lambda x:x.ID)
return min_obj

def sortTeamById(self):
s=[]
s=sorted(self.teamList,key=lambda x:x.ID)
s1=[]
for i in s:
s1.append(i.ID)
if len(s1)==0:
return None
else:
return s1

if __name__=='__main__':
teamList=[]
limit=int(input())
for j in range(limit):
owner=input()
value=float(input())
ID=int(input())
name=input()
teamList.append(Team(owner,value,ID,name))
obj=League("leagueName",teamList)
r1=obj.findMininumTeamByID()
if(r1!=None):
print(r1.owner)
print(r1.value)
print(r1.ID)
print(r1.name)
else:
print("No Data Found")

r2=obj.sortTeamById()
for i in r2:
print(i)

Unix
----------------------------------
awk 'BEGIN{ FS="|"}
{
if($4=="Sangamithra" && $5>=90 && $6>=90)
{
print $1"|"$2"|"$3"|"$4"|"($5+$6)/2;
}
} END{}'|sort -k5 -t'|'

You might also like