Question: create a pets.py module with a Pet superclass that defines common attributes - name, breed, age - where 'age' is in human years. create

create a pets.py module with a Pet superclass that defines common attributes


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

Step by Step Solution

3.32 Rating (164 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the petspy module with Pet Dog and Cat classes as requested class Pet def initself name breed ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!