logo

Crowdly

Browser

Add to Chrome

Mis prinditakse konsooli kui järgnev koodijupp tööle panna? class Animal: ...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Mis prinditakse konsooli kui järgnev koodijupp tööle panna?

class Animal:

def __init__(self, name, species):

self.name = name

self.species = species

def make_sound(self):

return "Some generic animal sound"

def __str__(self):

return f"{self.name} is a {self.species}"

class Dog(Animal):

def __init__(self, name, breed):

super().__init__(name, "Dog")

self.breed = breed

def make_sound(self):

return "Bark!"

def __str__(self):

return super().__str__() + f", and is of breed {self.breed}"

if __name__ == '__main__':

animal = Animal("Generic animal", "Some unknown species")

print(animal)

print(animal.make_sound())

dog = Dog("Buddy", "Golden Retriever")

print(dog)

print(dog.make_sound())

0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.taltech.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome