Rectangle Are Perimeter Program in Python


Given the length and breadth of a rectangle, write a program to find whether the area of the rectangle is greater than its perimeter. For example, the area of the rectangle with length = 5 and breadth = 4 is greater than its perimeter

This program is a basic implementation of a program that calculates the area and perimeter of a rectangle and then compares them.

  • The program first prompts the user to input the length and breadth of the rectangle using the "input" function and then converts them to float using the "float" function.
  • Next, the program calculates the area of the rectangle by multiplying the length and breadth, and assigns it to the variable "area". It also calculates the perimeter of the rectangle by adding the twice of the sum of length and breadth and assigns it to the variable "perimeter".
  • The program then uses an "if-else" statement to check if the area of the rectangle is greater than the perimeter or not. If the area is greater than the perimeter, it prints "Area of rectangle is greater than Perimeter" to the console. If the area is not greater than the perimeter, it prints "Perimeter of rectangle is greater than Area" to the console.
  • Finally, it prints the area and perimeter of the rectangle using the "print" function.

Source Code

len = float(input("Enter the Length : "))
bre = float(input("Enter the Breadth : "))
area = len * bre;
perimeter = 2 * (len+bre)
print("Area of Rectangle :", area)
print("Perimeter of Rectangle :", perimeter)
if (area>perimeter):
	print("Area of rectangle is greater than  Perimeter")
else:
	print("Perimeter of rectangle is greater than Area")

Output

Enter the Length : 12
Enter the Breadth : 13
Area of Rectangle : 156.0
Perimeter of Rectangle : 50.0
Area of rectangle is greater than  Perimeter


Example Programs