| 12345678910111213141516171819202122232425262728 |
- class Dog():
- """A simple attempt to model a dog."""
-
- def __init__(self, name, age):
- """Initialize name and age attributes."""
- self.name = name
- self.age = age
-
- def sit(self):
- """Simulate a dog sitting in response to a command."""
- print(self.name.title() + " is now sitting.")
- def roll_over(self):
- """Simulate rolling over in response to a command."""
- print(self.name.title() + " rolled over!")
-
- my_dog = Dog('willie', 6)
- your_dog = Dog('lucy', 3)
- print("My dog's name is " + my_dog.name.title() + ".")
- print("My dog is " + str(my_dog.age) + " years old.")
- my_dog.sit()
- print("\nMy dog's name is " + your_dog.name.title() + ".")
- print("My dog is " + str(your_dog.age) + " years old.")
- your_dog.sit()
|