This is a Python Program to find the area of a rectangle using classes.

The program takes the length and breadth from the user and finds the area of the rectangle using classes.

1. Take the value of length and breadth from the user.

2. Create a class and using a constructor initialise values of that class.

3. Create a method called as area and return the area of the class.

4. Create an object for the class.

5. Using the object, call the method area() with the parameters as the length and breadth taken from the user.

6. Print the area.

7. Exit

Here is the source code of the Python Program to take the length and breadth from the user and find the area of the rectangle. The program output is also shown below.

class rectangle(): def __init__(self,breadth,length): self.breadth=breadth self.length=length def area(self): return self.breadth*self.length a=int(input("Enter length of rectangle: ")) b=int(input("Enter breadth of rectangle: ")) obj=rectangle(a,b) print("Area of rectangle:",obj.area()) print()

1. User must enter the value of length and breadth.

2. A class called rectangle is created and the __init__() method is used to initialise values of that class.

3. A method called as area, returns self.length*self.breadth which is the area of the rectangle.

4. An object for the class is created.

5. Using the object, the method area() is called with the parameters as the length and breadth taken from the user.

6. The area is printed.

Case 1: Enter length of rectangle: 4 Enter breadth of rectangle: 5 Area of rectangle: 20 Case 2: Enter length of rectangle: 15 Enter breadth of rectangle: 13 Area of rectangle: 195

**Sanfoundry Global Education & Learning Series – Python Programs.**

To practice all Python programs, __here is complete set of 150+ Python Problems and Solutions__.

**Next Steps:**

- Get Free Certificate of Merit in Python Programming
- Participate in Python Programming Certification Contest
- Become a Top Ranker in Python Programming
- Take Python Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

**Related Posts:**

- Practice Programming MCQs
- Buy Information Technology Books
- Apply for Python Internship
- Buy Python Books
- Apply for Programming Internship