Advertisement
doxzter

беру портвейн иду домой

Jun 2nd, 2023 (edited)
564
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. # 2
  2.  
  3. import sys
  4.  
  5. if len(sys.argv) > 1:
  6.     for x in sys.argv[1:]:
  7.         print(len(x))
  8. else:
  9.     print(len(input()))
  10.  
  11. # 3
  12.  
  13. class Rectangle:
  14.     def __init__(self, w, h):
  15.         self.width = w
  16.         self.height = h
  17.    
  18.     def perimeter(self):
  19.         return (self.width+self.height)*2
  20.  
  21.     def area(self):
  22.         return self.width*self.height
  23.  
  24.     def is_square(self):
  25.         return self.width == self.height
  26.  
  27.     def __repr__(self):
  28.         name = 'Квадрат' if self.is_square() else 'Прямоугольник'
  29.         return f'{name}({self.width}x{self.height})'
  30.    
  31. test = Rectangle(5,5)
  32. print(test.perimeter())
  33. print(test.area())
  34. print(test.is_square())
  35. print(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement