In python: This file will contain functions that sort a list of…
Question In python: This file will contain functions that sort a list of… In python:This file will contain functions that sort a list of Apartment objects, ensures that the list of Apartment objects are in asending order (best-to-worst), retrives information about the best/worst apartments, and gets the info of every affordable apartment in the list. These function defintions as well as their descriptions are provided below. Note that in order for the autograder to correctly check your implementation, function defintions must match exactly.mergesort(apartmentList) – Performs a mergesort on the apartmentList passed as input. Sorts the Apartment objects based on the specifications in the Introduction section of this lab. Gradescope will test to ensure that your mergesort implementation’s Big-O is O(NlogN).ensureSortedAscending(apartmentList) – method that returns a boolean value. True if the apartmentList is sorted correctly in asending order. False otherwise.getBestApartment(apartmentList) – method that returns a string detailing the best Apartment’s rent, meters from UCSB, and condition. Make use of getApartmentDetails(self) and mergesort(apartmentList). You can assume that apartmentList has at least one apartment.getWorstApartment(apartmentList) – method that returns a string detailing the worst Apartment’s rent, meters from UCSB, and condition. Make use of getApartmentDetails(self) and mergesort(apartmentList). You can assume that apartmentList has at least one apartment.getAffordableApartments(apartmentList, budget) – method that returns a labeled, newline separated string detailing the rent, meters from UCSB, and condition of all the apartments whose rent is less than or equal to budget from the apartmentList in sorted order. Make use of getApartmentDetails(self) and mergesort(apartmentList). You can assume that apartmentList has at least one apartment and that there is no newline at the end of the string returned by this method. If there are no apartments that are affordable in the apartmentList, this method returns an empty string.Sample Output 2a0 = Apartment(1200, 200, “average”)a1 = Apartment(1200, 200, “excellent”)a2 = Apartment(1000, 100, “average”)a3 = Apartment(1000, 215, “excellent”)a4 = Apartment(700, 315, “bad”)a5 = Apartment(800, 250, “excellent”)apartmentList = [a0, a1, a2, a3, a4, a5]assert ensureSortedAscending(apartmentList) == Falseprint(‘Best Apartment in apartmentList:’)print(getBestApartment(apartmentList))print(‘Worst Apartment in apartmentList:’)print(getWorstApartment(apartmentList))Output:Best Apartment in apartmentList: (Apartment) Rent: $700, Distance From UCSB: 315m, Condition: badWorst Apartment in apartmentList:(Apartment) Rent: $1200, Distance From UCSB: 200m, Condition: average Computer Science Engineering & Technology Python Programming CS 5 Share QuestionEmailCopy link Comments (0)


