In this post, we will learn a python program to calculate the area of a rectangle with a very basic explanation and example.

So let us start learning from the very basics…

Formula For Area of Rectangle

The formula is: Area = l * b

• Where Area is area of Rectangle
• l is length of the Rectangle
• b is breadth of the Rectangle

Algorithm for Area of Rectangle

1. Ask the user for the input of the length (`l`) and breadth (`b`) of the rectangle using an `input()` function.
2. Using the formula calculate the area of the rectangle (`area = l * b`).
3. At the end, print the result (`print(area)`).

From the formula and algorithm, we understood how to implement a python program to calculate the area of the rectangle but before writing a program few programming concepts you have to know:

Source Code

``````l = float(input('Enter Length of the Rectangle: '))
b = float(input('Enter Breadth of the Rectangle: '))

area = l * b

print(f"Area of rectangle is {area:.2f}")``````

Output

Now let us modify the above program and write it using the function.

Calculate the Area of Rectangle Using Function

But before writing this program you should know about:

Source Code

``````def Area_of_rectangle(length, breadth):