Answer
t.me/python_tesstОтвет:
I am a German Shepard
I am 3 years old
Объяснение:
Две внутренние функции bark
и reveal_information
являются методами, выполняемыми и прикрепляемыми классом. Затем мы можем задать переменную pepper
классу dpg
. Мы должны указать параметры инициализации species
и age.
Затем можем вызвать атрибуты pepper
Код:
class dog: def __init__(self, species, age): self.species = species self.age = age def bark(self, call='Woof!'): print(call) def reveal_information(self): print('I am a', self.species) print('I am', self.age, 'years old') pepper = dog(species='German Shepard', age=3) pepper.reveal_information()