Answer:
class Rectangle():
def __init__(self, l, w):
self.len = l
self.wi = w
def area(self):
return self.len*self.wi
def perimeter(self):
return self.len+self.len+self.wi+self.wi
def printing(self):
print('{} Lenght X Width {}'.format(self.len, self.wi))
length = int(input("enter the length "))
width = int(input("enter the width "))
newRectangle = Rectangle(length, width)
newRectangle.printing()
print("Area is: ")
print(newRectangle.area())
print("The perimeter is: ")
print(newRectangle.perimeter())
Explanation:
The class rectangle is defined with a constructor that sets the length and width
As required the three methods Area, perimeter and printing are also defined
The input function is used to prompt and receive user input for length and width of the rectangle
An object of the Rectangle class is created and initalilized with the values entered by the user for length and width
The three methods are then called to calculate and return their values