Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
multiline f-strings solution in Clear category for Building Base by David_Jones
class Building():
def __init__(self, south, west, width_we, width_ns, height=10):
self.south = south
self.west = west
self.width_we = width_we
self.width_ns = width_ns
self.height = height
def corners(self):
north = self.south + self.width_ns
east = self.west + self.width_we
return {
'north-west': [north, self.west],
'south-west': [self.south, self.west],
'north-east': [north, east],
'south-east': [self.south, east]
}
def area(self):
return self.width_we * self.width_ns
def volume(self):
return self.area() * self.height
def __repr__(self):
return (
f'Building({self.south}, {self.west}, '
f'{self.width_we}, {self.width_ns}, {self.height})'
)
May 17, 2019