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
-
Draw the p orbital's that compose the conjugated part of these molecules: a) :-CH3 b) CH,=CHNH, c) H-C-C-CH=CH
-
The following was reported in Shania Ltd.s 2014 financial statements. Calculate cash payments for dividends? 2014 2013 Dividends payable Retained earnings Profit $ 24,000 $ 20,000 261,000 114,000...
-
Testing IRP. The 1-year interest rate in Singapore is 11 percent. The 1-year interest rate in the United States is 6 percent. The spot rate of the Singapore dollar (S$) is $.50 and the forward rate...
-
C&C Properties is an S corporation that owns two rental real estate undertakings: Carrot Plaza and Cantaloupe Place. Both properties produce an annual $10,000 operating loss. C&Cs Schedule K...
-
A manufacturer estimates total factory overhead costs of $4,704,000 and total direct labor costs of $2,240,000 for its first year of operations. During January, the company used $110,000 of direct...
-
Blue Angel Investors has a success ratio of 10% with its venture funding. Blue Angel requires a rate of return of 20% for its portfolio of lending, and the average length on its loan is five years....
-
The Washington State legislature is trying to decide on locations at which to base search-and-rescue teams. The teams are expensive, so the legislature would like as few as possible while still...
-
You have been appointed as Production Chef for XYZ company which is a catering company that produces about 15,000 meals a day in terms of meal production. Central kitchen operations start from Menu...
-
Read each situation and decide whether or not it was a legal search based on your understanding of students' privacy rights. Explain your answer. Situation School administrators receive a report that...
-
The purpose of an accounting system analysis is to develop a user-oriented system that will meet the needs of the organization over the long term. Which of the would have a direct impact on an...
-
A particle moves along a line so that its position at time ( t ) is given by ( s(t) = t^3 - 6t^2 + 9t ). Find the time intervals on which the particle is speeding up and slowing down.
-
The kinetic friction coefficient m 1 and surface is 0 . 1 the system starts from rest. the speed of m 2 is 6 m / s when it has fallen 2 m . if m 1 = 2 kg what is ma ? use the conservation of...
-
mework: Section 4.5 K Part 2 of 2 In 2 Use the formula t that gives the time for a population, with a growth rate k, to double, to answer the following questions. The growth model A=70.005t describes...
-
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...
-
Brandon Company produces and sells a product that has variable costs of $9 per unit and fixed costs of $110,000 per year. 1. Compute the unit cost at a production and sales level of 10,000 units per...
-
Evaluating performance, decision by decision, is costly. Aggregate measures, like the income statement, are frequently used. How might the wide use of income statements affect managers decisions...
-
An administrator at Riverview Hospital is considering how to use some space made available when the outpatient clinic moved to a new building. She has narrowed her choices as follows: a. Use the...
Study smarter with the SolutionInn App