Python: Finding area of rectangle

The program shown below calculates the area of the rectangle for given user inputs of length and width.

#Program:

length = int(input("Enter the length of the Rectangle "))

width = int(input("Enter the width of the Rectangle "))

class Rectangle:

    def __init__(self, length, width):

        self.length = length

        self.width = width


    def area(self):

        rect_area = self.length*self.width

        print("Area of the Rectangle = ", rect_area)

 

area1 = Rectangle(length, width)

area1.area()

Output:

Enter the length of the Rectangle 7

Enter the width of the Rectangle 9

Area of the Rectangle =  63

Comments

Popular posts from this blog

Continuous Wave Radar

Digital design fundamentals

Frequency Modulated Continuous Wave Radar