Answer:
class Rectangle:
def __init__(self, length=1, width=1):
self.length = length
self.width = width
def Area(self):
return self.length * self.width
def Perimeter(self):
return 2 * (self.length + self.width)
def Print(self):
print(str(self.length) + " X " + str(self.width))
l = float(input("Enter the length: "))
w = float(input("Enter the width: "))
a = Rectangle(l, w)
print(str(a.Area()) + " " + str(a.Perimeter()))
a.Print()
Explanation:
Create a class called Rectangle
Create its constructor, that sets the length and width
Create a method Area to calculate its area
Create a method Perimeter to calculate its perimeter
Create a Print method that prints the rectangle in the required format
Ask the user for the length and width
Create a Rectangle object
Calculate and print its area and perimeter using the methods from the class
Print the rectangle