PY
py
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
class Shape:
def __init__(self, w, h):
self.width = w
self.height = h
def area(self):
return self.width*self.height
#your code
def __add__(self,other):
return Shape(self.width+other.width,self.height+other.height)
def __gt__(self,other):
return self.area()>other.area()
w1 = int(input())
h1 = int(input())
w2 = int(input())
h2 = int(input())
s1 = Shape(w1, h1)
s2 = Shape(w2, h2)
result = s1 + s2
print(result.area())
print(s1 > s2)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run