-
Notifications
You must be signed in to change notification settings - Fork 0
/
class_example.py
48 lines (38 loc) · 1.04 KB
/
class_example.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class room():
def __init__(self):
self.length = None
self.width = None
self.height = None
def size(self):
return self.length*self.width
def volume(self):
return self.length*self.width*self.height
class house(room):
def __init__(self, l, w, h=10):
self.length = l
self.width = w
self.height = h
self.address = None
self.phone = None
self.Members = None
self.kitchen_p = kitchen(10, 10, 10)
self.bedroom_p = bedroom(10, 10, 8)
def print_details(self):
print(f'{self.address} - {self.phone} - {self.Members}')
class kitchen(room):
def __init__(self, l, w, h):
self.length = l
self.width = w
self.height = h
class bedroom(room):
def __init__(self, l, w, h):
self.length = l
self.width = w
self.height = h
list_of_house = []
for x in range(1, 11):
h = house(100, 100)
h.address = x
h.phone = x*x
h.Members = (x*x) + (x*x)
list_of_house.append(h)