Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 2
- import sys
- if len(sys.argv) > 1:
- for x in sys.argv[1:]:
- print(len(x))
- else:
- print(len(input()))
- # 3
- class Rectangle:
- def __init__(self, w, h):
- self.width = w
- self.height = h
- def perimeter(self):
- return (self.width+self.height)*2
- def area(self):
- return self.width*self.height
- def is_square(self):
- return self.width == self.height
- def __repr__(self):
- name = 'Квадрат' if self.is_square() else 'Прямоугольник'
- return f'{name}({self.width}x{self.height})'
- test = Rectangle(5,5)
- print(test.perimeter())
- print(test.area())
- print(test.is_square())
- print(test)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement