Sunday, April 21st at 11:59 PM.
DeliverablesThere is one deliverable for this assignment:
It must be in an hw10 directory, which you must create inside a hw directory inside you it117 directory.
Make sure the script obeys all the rules in the Script Requirements page.
SpecificationYour hw10.py must contain the definition of the class Pet with hidden fields containing
The constructor should take one argument, the name of the pet.
It should set the type to the empty string and the age to
The class should have the following public functions
set_type should print an error message if the type is not 'cat' or 'dog'.
get_age should use a conversion function to set the age attribute to an integer.
It should catch the exception cause by calling set_age with an argument that cannot be turned into an integer and print an error message when this happens.
It should also have the following magic methods
The __sub__ method should return the integer you get from subtracting the age of another Pet object from the age of the object.
older should print the messages you will see below in the testing code.
You MUST add the following test code to your hw10.py script.if __name__ == '__main__': p1 = Pet('Henry') p1.set_type('dawg') p1.set_type('dog') p1.set_age('seven') p1.set_age('7') print(p1.get_name()) print(p1.get_type()) print(p1.get_age()) print(p1) p2 = Pet('Felix') p2.set_age(2) p2.older(p1) p1.older(p2) p3 = Pet('Angus') p3.set_age(7) p3.older(p1) p1.older(p3)Your output should look something like this$ ./hw10.py dawg is not a valid pet type seven cannot be converted into an integer Henry dog 7 Henry, dog Felix is younger than Henry Henry is older than Felix Henry and Angus are the same age Angus and Henry are the same ageBe sure to run this script on the Unix machine so you know it works in the environment in which I will run it when I score your homework.