-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdog.py
26 lines (20 loc) · 771 Bytes
/
dog.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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("\nYour dog's name is " + your_dog.name.title() + ".")
print("You dog is " + str(your_dog.age) + " years old")
your_dog.sit()