Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python! lab06.py This file will contain functions that sort a list of Apartment objects, ensures that the list of Apartment objects are in ascending

image text in transcribedIn Python!

lab06.py This file will contain functions that sort a list of Apartment objects, ensures that the list of Apartment objects are in ascending (best-to-worst) order according to the specification, retrives information about the nth apartment in the list, and gets the top three apartments from the sorted list. These function defintions as well as their descriptions are provided below. Note that in order for the autograder to correctly check your implementation, your function defintions must match exactly as the given specifications. 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(n log n) ensureSortedAscending (apartmentList) - method that returns a boolean value. Returns True if the apartmentList is sorted correctly in asending order. Returns False otherwise getNthApartment (apartmentList, n) - method that returns a string detailing the Apartment's rent, meters from UCSB, and condition at index n. Note that there is no newline (" ") at the end of the string returned by this method. Make use of the getApartmentDetails(self) method you defined in Apartment.py. If the nth apartment does not exist, output" (Apartment) DNE" (see Sample Output 3 below) getTopThreeApartments(apartmentList) - method that returns a labeled, newline separated string detailing the rent, meters from UCSB, and condition of the top three best apartments from the apartmentList. Note that there can be fewer that three apartments in your list and there is no newline at the end of the string returned by this method. You may assume that apartmentList is non-empty. HINT: Make use of the getApartmentDetails(self) and mergesort(apartmentList) you defined in lab06.py. Sample Output 1 al = Apartment(1200, 200, "average") al = Apartment(1200, 200, "excellent") a2 = Apartment (1000, 100, "average") a3 = Apartment (1000, 215, "excellent") a4 = Apartment (700, 315, "bad") a5 = Apartment (800, 250, "excellent") lab06.py This file will contain functions that sort a list of Apartment objects, ensures that the list of Apartment objects are in ascending (best-to-worst) order according to the specification, retrives information about the nth apartment in the list, and gets the top three apartments from the sorted list. These function defintions as well as their descriptions are provided below. Note that in order for the autograder to correctly check your implementation, your function defintions must match exactly as the given specifications. 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(n log n) ensureSortedAscending (apartmentList) - method that returns a boolean value. Returns True if the apartmentList is sorted correctly in asending order. Returns False otherwise getNthApartment (apartmentList, n) - method that returns a string detailing the Apartment's rent, meters from UCSB, and condition at index n. Note that there is no newline (" ") at the end of the string returned by this method. Make use of the getApartmentDetails(self) method you defined in Apartment.py. If the nth apartment does not exist, output" (Apartment) DNE" (see Sample Output 3 below) getTopThreeApartments(apartmentList) - method that returns a labeled, newline separated string detailing the rent, meters from UCSB, and condition of the top three best apartments from the apartmentList. Note that there can be fewer that three apartments in your list and there is no newline at the end of the string returned by this method. You may assume that apartmentList is non-empty. HINT: Make use of the getApartmentDetails(self) and mergesort(apartmentList) you defined in lab06.py. Sample Output 1 al = Apartment(1200, 200, "average") al = Apartment(1200, 200, "excellent") a2 = Apartment (1000, 100, "average") a3 = Apartment (1000, 215, "excellent") a4 = Apartment (700, 315, "bad") a5 = Apartment (800, 250, "excellent")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago