class Dog():
def init(self, name, age):
self.name = name
self.age = age
def sit(self):
print(self.name.title() + " is now sitting.")
def roll_over(self):
print(self.name.title() + " rolled over!")
my_dog = Dog(‘willie’, 6)
your_dog = Dog(‘Lucy’, 8)
print("My dog’s name is " + my_dog.name.title() + “.”)
print(“My dog is " + str(my_dog.age) + " years old.”)
my_dog.sit()
print("\nYour dog’s name is " + your_dog.name.title() + “.”)
print(“Your dog is " + str(your_dog.age) + " years old.”)
your_dog.sit()
Python-console:
My dog’s name is Willie.
My dog is 6 years old.
Willie is now sitting.
Your dog’s name is Lucy.
Your dog is 8 years old.
Lucy is now sitting.