In this article we will show you, How to write Python Program to find Area of a Rectangle and Perimeter of a Rectangle with example. Before we step into the program, Let see the definitions and formulas behind Perimeter and Area Of a Rectangle.

## Area of a Rectangle

If we know the width and height then, we can calculate the area of a rectangle using below formula.

Area = Width * Height

Perimeter is the distance around the edges. We can calculate perimeter of a rectangle using below formula

Perimeter = 2 * (Width + Height)

### Python Program to find Area of a Rectangle and Perimeter of a Rectangle

This python program allows the user to enter width and height of the rectangle. Using those values we will calculate the Area of a rectangle and perimeter of a rectangle.

**PYTHON CODE**

# Python Program to find Area of a Rectangle width = float(input('Please Enter the Width of a Rectangle: ')) height = float(input('Please Enter the Height of a Rectangle: ')) # calculate the area Area = width * height # calculate the Perimeter Perimeter = 2 * (width + height) print("\n Area of a Rectangle is: %.2f" %Area) print(" Perimeter of Rectangle is: %.2f" %Perimeter)

**OUTPUT**

**ANALYSIS**

Following statements will allow the User to enter the Width and Height of a rectangle.

width = float(input('Please Enter the Width of a Rectangle: ')) height = float(input('Please Enter the Height of a Rectangle: '))

Next, we are calculating the area as per the formula

Area = width * height

In the next line, We are calculating the Perimeter of a rectangle

Perimeter = 2 * (width + height)

Following print statements will help us to print the Perimeter and Area of a rectangle

print("\n Area of a Rectangle is: %.2f" %Area) print(" Perimeter of Rectangle is: %.2f" %Perimeter)

### Python Program to find Area of a Rectangle using functions

This program allows the user to enter the width and height of a rectangle. We will pass those values to the function arguments to calculate the area of a rectangle.

**PYTHON CODE**

# Python Program to find Area of a Rectangle using Functions def Area_of_a_Rectangle(width, height): # calculate the area Area = width * height # calculate the Perimeter Perimeter = 2 * (width + height) print("\n Area of a Rectangle is: %.2f" %Area) print(" Perimeter of Rectangle is: %.2f" %Perimeter) Area_of_a_Rectangle(6, 4)

**ANALYSIS**

First, We defined the function with two arguments using def keyword. It means, User will enter the width and height of a rectangle. Next, We are Calculating the perimeter and Area of a rectangle as we described in our first example.

**OUTPUT**

**NOTE:** We can call the function with arguments in .py file directly or else we can call it from the python shell. Please don’t forget the function arguments

Thank You for Visiting Our Blog