PYTHON CORE · LESSON 50
Bottom line: cat says
My method in class. · about 18 minutes
Learning with progressRead the summary for free. To save the work, log in to the account.
Type the code yourself
Reprint the full class: name and action.
class Dog:
def __init__(self, name):
self.name = name
def speak(self):
return "Гав, " + self.name
pet = Dog("Рекс")
print(pet.speak())Open the editor for class workSolve it yourself
Create Cat: __init__ saves name to self.name, and speak returns «Мяу, » plus that name. Create pet with the name «Мур» and output the result pet.speak().
The answer is hidden. Use similar examples from the lesson notes.
Opening up your homework