Click one of the ads shown :
Define class Rectangle
The program must accept the length the breadth of N rectangles and an integer X as the input. The program m the total area of the N rectangles. Then the program must remove the X rectangle from the N rectangles. Then t breadth and the area of N-1 rectangles as shown in the Example Input/Output section. Finally, the program must a and the total area of the remaining rectangles as the output
Your task is to define the class Rectangle so that the program runs successfully.
Boundary Condition(s):
2<N<= 50
1 <= x <= N
Example Input/Output 1:
Input:
25
38 163
54
Output
96
Length-2, Breadth 5 Area
10
Length Breadth=8 Area-24 Length 6 Breadth 3 Area 18
Length 5 Breadth 4 Area 20
PYTHON CODE :
CHECK INDENTATION & VIEW THIS PAGE IN DESKTOP MODE
class Rectangle:
rectangleCount=0
totalArea=0
def __init__(self,length,breadth):
self.length = length
self.breadth = breadth
Rectangle.rectangleCount+=1
Rectangle.totalArea+=self.length*self.breadth
def __del__(self):
Rectangle.rectangleCount-=1
Rectangle.totalArea-=self.length*self.breadth
def __repr__(self):
return "Length={}, Breadth={}, Area={}".format(self.length,self.breadth,self.length*self.breadth)
Post a Comment