Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started