-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdog_class.py
More file actions
36 lines (26 loc) · 1 KB
/
dog_class.py
File metadata and controls
36 lines (26 loc) · 1 KB
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
27
28
29
30
31
32
33
34
35
36
class Dog():
# Class Attributes
species = 'mammal'
# initializer / Instance attributes
def __init__(self, name, age, breed):
self.name = name
self.age = age
self.breed = breed
# Initiate the Dog Object
Rocky = Dog('Rocky', 8, 'German Sheperd')
Rani = Dog('Rani', 10, 'Doberman')
Simba = Dog('Simba', 12, 'Labrador')
# Access the instance attributes
print("{} is a {} and he is {} years old.".format(Rocky.name, Rocky.breed,
Rocky.age))
print("{} is a {} and she is {} years old".format(Rani.name, Rani.breed,
Rani.age))
# Checking for mammal
if (Rocky.species == 'mammal'):
print("{} is a {}".format(Rocky.name, Rocky.species))
# Determine the oldest dog
def get_oldest_dog(*args):
return max(args)
# Output
print("The oldest dog is {} years old.".format(get_oldest_dog(Rocky.age, Rani.
age, Simba.age)))