35 lines
778 B
Python
35 lines
778 B
Python
class Rect:
|
|
def __init__(self, height: int, width: int):
|
|
if height < 0 or width < 0:
|
|
raise ValueError('Длины сторон не могут быть отрицательными')
|
|
self.height = height
|
|
self.width = width
|
|
|
|
def area(self):
|
|
return self.height * self.width
|
|
|
|
def perimeter(self):
|
|
return 2 * (self.height + self.width)
|
|
|
|
def scale(self, multiplier):
|
|
self.height *= multiplier
|
|
self.width *= multiplier
|
|
|
|
def rotate(self):
|
|
tmp = self.height
|
|
self.height = self.width
|
|
self.width = tmp
|
|
|
|
|
|
def main():
|
|
r1 = Rect(10, 56)
|
|
print(r1.area())
|
|
print(r1.perimeter())
|
|
r1.scale(10)
|
|
r1.scale(0.1)
|
|
r1.rotate()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|