Your Perfect Assignment is Just a Click Away

We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

Foothill College Object Oriented Design Python Project

Foothill College Object Oriented Design Python Project

I’m trying to learn for my Python class and I’m stuck. Can you help?

a short code that:

Demonstrate an understanding of:

  • List creation
  • List comprehensions
  • Custom exceptions 
  • Tuples
  • Built-in functions: min(), max(), sum(), len()

Specification

Start with your code from assignment six. I will send this one a tutor is chosen!

DataSet Class

Add the following to your DataSet class:

EmptyDatasetError exception

This exception will be raised when a method is asked to do calculation on the dataset, but no data is loaded.

_cross_table_statistics(self, descriptor_one: str, descriptor_two: str)

The two parameters of this function (descriptor_one and descriptor_two) describe a borough and property type.  Use a list comprehension to create a list of rents for all properties that match both descriptors.   If no properties matched both descriptors, return a tuple None, None, None.  Otherwise return the minimum, average, and maximum rent as a tuple of floats. 

load_default_data(self)

Later in the course we will load data from a file.  For now we just want some data to play with.  This function should simply load the following data into self._data as a list of tuples.

Borough

Type

Rate per Night

Staten Island

Private room

70

Brooklyn

Private room

50

Bronx

Private room

40

Brooklyn

Entire home / apt

150

Manhattan

Private room

125

Manhattan

Entire home / apt

196

Brooklyn

Private room

110

Manhattan

Entire home / apt

170

Manhattan

Entire home / apt

165

Manhattan

Entire home / apt

150

Manhattan

Entire home / apt

100

Brooklyn

Private room

65

Queens

Entire home / apt

350

Manhattan

Private room

99

Brooklyn

Entire home / apt

200

Brooklyn

Entire home / apt

150

Brooklyn

Private room

99

Brooklyn

Private room

120

Modifications to Existing Code

There are no modifications needed for this assignment

Unit Test

Our code for this assignment will not generate any different output if you run main(), so create a simple unit test function for _cross_table_statistics.  All of these items should be tested within that function, and the function should report pass or fail for each.

  • In your unit test, create an instance of the class DataSet.  I’ll call it my_set here, you can choose whatever name you like.
  • Before calling my_set.load_default_data, call my_set._cross_table_statistics and ensure that it raises EmptyDataSet.
  • Next load the default data.
  • Calculate the expected results of several calls by hand and compare the result with the return value of my_set._cross_table_statistics.  Include: 
    • A call with a match in the Borough column but an invalid Property Type (should return None, None, None)
    • A call with a match in the Property Type column but an invalid  Borough (should return None, None, None)
    • A call with valid entries for both columns but no match (should return None, None, None)
    • A call that will match exactly one item in the table
    • A call that will match more than one item in the table
    • Any other important cases you can think of

Be sure to include the code for your unit test in your homework submission.  In my solution, I just created a function called unit_test() and included it in the same file.

Sample Run

Your output can be different as long as it meets the criteria above.

Testing _cross_table_staticstics
Method Raises EmptyDataSet Error: Pass
Invalid Property Type Returns None Tuple: Pass
Invalid Borough Returns None Tuple: Pass
No Matching Rows Returns None Tuple: Pass
One Matching Row Returns Correct Tuple: Pass
Multiple Matching Rows Returns Correct Tuple: Pass

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: School Assignment only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by School Assignment are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. School Assignment is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At School Assignment, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.