-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapartment3.py
More file actions
executable file
·38 lines (29 loc) · 992 Bytes
/
apartment3.py
File metadata and controls
executable file
·38 lines (29 loc) · 992 Bytes
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
"""
apartment.py
Chapter 7 Cool Features of Python
Author: William C. Gunnells
Rapid Python Programming
"""
class Complex(object):
def __init__(self, unit, parking, pool, rooms, people):
self.unit = unit
self.parking = parking
self.pool = pool
self.rooms = rooms
self.people = people
self.capacity = 0
self.uncovered = 0
self.free_rooms = 0
def calc(self):
self.capacity = float(self.people) / self.rooms
self.uncovered = 100 - (float(self.parking) / self.people * 100)
self.rooms = 10 * 2
self.free_rooms = self.rooms - self.people
def result(self):
self.calc()
print("The complex is at %g capacity" % self.capacity)
print("There are %g percent people with uncovered parking" % self.uncovered)
print("We have %g rooms" % self.rooms)
print("We have %g free rooms left" % self.free_rooms)
myCo = Complex(10, 8, 1, 20, 15)
myCo.result()