Answered step by step
Verified Expert Solution
Link Copied!

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 __init__(self, species, name, gender, birth_year):
self.species = species
self.name = name
self.gender = gender
self.birth_year = birth_year
def age(self):
now = datetime.datetime.now()
current_year = now.year
return( current_year - self.birth_year )
def __repr__(self):
return('Hello I am a '+ str(self.species)+' named '+ self.name +' and I am '+ str(self.age())+" years old")
class Dog(Animal):
def __init__(self, name, gender, birth_year, breed):
super().__init__('Dog', name, gender, birth_year)
self.breed = breed
def __repr__(self):
return("Hello I am a dog named "+ self.name +". I'm an "+ self.breed +" and I'm "+ str(self.age())+" years old")
def fetch(self, distance):
print("RuffRuff: I fetched a stick thrown "+ str(distance)+" yards. I ran a total of "+ str(distance *2)+" yards there and back.")
class Cat(Animal):
def __init__(self, name, gender, birth_year, breed):
super().__init__("Cat", name, gender, birth_year)
self.breed = breed
def purr(self):
str =""",__,
|\"\\___//|
|=66=|
\=._Y_.=/
)`(
/\((
||))
/||||\_//
\||._.||/-`
'"''"'"""
print(str)
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is commodity money? What is fiat money? Which kind do we use?

Answered: 1 week ago