Python Programming : Area and Perimeter of Rectangle

Example

Input
enter the length 5 
enter the breadth 6 
Output 
Area is 30 
Perimeter is 22

Required to Know

Use of Variables, Use of different operators like assignment or arithmetic operators, Use of functions like print(), and input(), and Use of Data types.

Formula

Area of rectangle = length * breadth 
Perimeter of the rectangle = 2 * (length + breadth)

Steps

  1. Take length and breadth as input from the user.

  2. Use the formula to find the area and perimeter of the rectangle.

  3. Print area and perimeter.

Program

# Get the length and breadth of the rectangle from the user
length = int(input("Enter the length of the rectangle: "))
breadth = int(input("Enter the breadth of the rectangle: "))
# Calculate the area of the rectangle
area = length * breadth
# Calculate the perimeter of the rectangle
perimeter = 2 * (length + breadth)
# Print the area and perimeter of the rectangle
print("Area is", area)
print("Perimeter is", perimeter)