create a pets.py module with a Pet superclass that defines common attributes - name, breed, age...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
create a pets.py module with a Pet superclass that defines common attributes - name, breed, age - where 'age' is in human years. • create Cat and Dog subclasses that inherit from Pet and implement methods to calculate appropriate 'animal' years and print pet information. • create a __repr__ method for each class that prints information about the object like so: "Name: fido, Breed: great dane, Age: 6 (44 dog yrs)" Other programs should be able to import your pets.py module and perform operations like below: . from pets import * d = Dog('fido', 'great dane', 6) c = Cat('sparky', 'siamese', 6) print(d) # should print something like "Name: fido, Breed: great dane, age: 6 (44 dog yrs)" print(c) # should print something like "Name: sparky, Breed: siamese, age: 6 (40 cat yrs)" Hints • See the notes in Canvas for an example of class inheritance • Each of your sub-classes will need a method to calculate non-human age. Ideally, you would name this method the same in each sub-class, • Your age calculations can re-use logic from the previous Dog Years assignment, • Each subclass should have it's own__repr__method to allow class-specific variation create a pets.py module with a Pet superclass that defines common attributes - name, breed, age - where 'age' is in human years. • create Cat and Dog subclasses that inherit from Pet and implement methods to calculate appropriate 'animal' years and print pet information. • create a __repr__ method for each class that prints information about the object like so: "Name: fido, Breed: great dane, Age: 6 (44 dog yrs)" Other programs should be able to import your pets.py module and perform operations like below: . from pets import * d = Dog('fido', 'great dane', 6) c = Cat('sparky', 'siamese', 6) print(d) # should print something like "Name: fido, Breed: great dane, age: 6 (44 dog yrs)" print(c) # should print something like "Name: sparky, Breed: siamese, age: 6 (40 cat yrs)" Hints • See the notes in Canvas for an example of class inheritance • Each of your sub-classes will need a method to calculate non-human age. Ideally, you would name this method the same in each sub-class, • Your age calculations can re-use logic from the previous Dog Years assignment, • Each subclass should have it's own__repr__method to allow class-specific variation
Expert Answer:
Answer rating: 100% (QA)
Heres the petspy module with Pet Dog and Cat classes as requested class Pet def initself name breed ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Should pet supply companies like PETCO be held responsible for the conditions at pet breeders and suppliers? How do you think exposs on poor breeder conditions have affected PETCOs reputation? PETCO...
-
Below are eight common methods that project and functional employees can use to provide communications: a. Counseling sessions e. Project office memo b. Telephone conversation f. Project office...
-
The following information relates to Dane City during its fiscal year ended December 31, 20X2: 1. On October 31, 20X2, to finance the construction of a city hall annex, Dane issued 8 percent, 10-year...
-
Show that = E[(m(X) - X'p)] B = argmind (b) = (E[XX']) E[Xm(X)] = [E[XX'])E[XY]. berk Hint: To show E[Xm(X)] = E[XY] use the law of iterated expectations. then
-
Describe ways that managers can process the information they collect.
-
You finance a new car with a 7 percent loan for 80 percent of the car value. The ination premium is 3.0 percent. If the risk premium is 2 percent, what is the pure rate using the multiplicative form?
-
What are the uses and benefits of workforce management systems/HRP systems? Check one of the websites mentioned in this chapter to obtain this information.
-
Zimmerman Companys annual accounting year ends on December 31. It is December 31, 2014, and all of the 2014 entries except the following adjusting entries have been made: a. On September 1, 2014,...
-
Horton Manufacturing Incorporated produces blinds and other window treatments for residential homes and offices. The owner is concerned about the maintenance costs for the production machinery...
-
a. What is the cost per camera (ignoring taxes) for Edwards Electronics and for Sears? b. For each store, what is the minimum selling price required to cover cost, over-head, and desired profits? c....
-
Topwood Ltd is a 40-year-old company producing furniture. 22 years ago, it acquired a 100% interest in Fleetwood Ltd. In 2011, it acquired a 40% interest in Landscapes Ltd and on 1 April 2013, it...
-
Musashi Ltd. commenced operations on January 1, 2016. on that day, it bought: Equipment costing 3.6 million, with a useful life of 3 years. Furniture and fittings costing 2.4 million, with a useful...
-
An acre (43,560 SF) of land in the Central Business District (CBD) is being used as an open parking lot. The land currently brings an operating cashflow of $28/SF/year, paid in arrears, which is...
-
Some companies like Facebook Inc. have two stages of growth, a fast rate for the next few years and then a slower rate for years after this. The valuation of a company like this will have two parts;...
-
Consider a one-period economy with two times, 0 and T. There are S = 3 states and N = 2 securities with payoffs and prices p = [10, 10]'. D = ( 10 9 10 10 10 11 (a) Does this market satisfy the Law...
-
Fox Manufacturing Company Income Statement for the Year Ended December 31, 2021 Sales revenue Less: Cost of goods sold Gross profits Less: Operating expenses General and administrative expenses...
-
Sanjay a good employee. His employer, Astra Company, a CCPC, rewards Sanjay with stock options for 100 shares on June 22nd, 2020. The options have an exercise price of $21 and the price was $23 on...
-
A heat engine has a heat input of 3 Ã 104 Btu/h and a thermal efficiency of 40 percent. Calculate the power it will produce, in hp. Source 3 x 10 Btu/h 40% HE Sink
-
Refer to the British Journal of Sports Medicine (Apr. 2000) study of the effect of massage on boxing performance, presented in Exercise. Two other variables measured on the boxers were blood lactate...
-
Three people play a game called "Odd Man Out." In this game, each player flips a fair coin until the outcome (heads or tails) for one of the players is not the same as that for the other two players....
-
To help students organize global information about people, places, and environments, geographers encourage them to develop mental maps of the world. A series of lessons was designed to aid students...
-
A football is thrown on a long pass. Compared to the balls initial horizontal velocity component, the velocity at the highest point is (a) greater, (b) less, (c) the same.
-
What process do you follow to make decisions for these different circumstances, and are you satisfied with the results?
-
A football is thrown on a long pass. Compared to the balls initial vertical velocity, the vertical component of its velocity at the highest point is (a) greater, (b) less, (c) the same.
Study smarter with the SolutionInn App