class Dog: def __init__(self, name, age): self.name = name self.age = age def bark(self): print(f"{self.name} says Woof!") my_dog = Dog(name="Buddy", age=3) print(f"My dog's name is {my_dog.name} and age is {my_dog.age}.") my_dog.bark()
Output:
My dog’s name is Buddy and age is 3.
Buddy says Woof!