Question: Copy the following Python code into a new, blank Python file in Spyder. Save this new file as animals.py import datetime class Animal: def _
Copy the following Python code into a new, blank Python file in Spyder. Save this new file as animals.py
import datetime
class Animal:
def initself species, name, gender, birthyear:
self.species species
self.name name
self.gender gender
self.birthyear birthyear
def ageself:
now datetime.datetime.now
currentyear now.year
return currentyear self.birthyear
def reprself:
returnHello I am a strselfspecies named self.name and I am strselfage years old"
class DogAnimal:
def initself name, gender, birthyear, breed:
superinitDog name, gender, birthyear
self.breed breed
def reprself:
returnHello I am a dog named self.name Im an self.breed and Im strselfage years old"
def fetchself distance:
printRuffRuff: I fetched a stick thrown strdistance yards. I ran a total of strdistance yards there and back."
class CatAnimal:
def initself name, gender, birthyear, breed:
superinitCat name, gender, birthyear
self.breed breed
def purrself:
str
Y
printstr
Once you copied it run the file. Did it run? If not, you may have copied it incorrectly.
Yes
No
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
