Python Program to Find Perimeter of Rectangle

A Rectangle is a planar shape which have its opposite sides being equal like a closed shape having sides as 3, 3, 6, 6 with opposite sides being equal will be a Rectangle. Mathematically Perimeter of Rectangle can be calculated by just adding all of four sides. For example – If rectangle have sides 7, 7, 4, 4 then perimeter will be 7 + 7 + 4 + 4 = 22, in order words if rectangle have sides defined as x, x, y, y where x is length and y is height => then perimater will be 2 * (x + y). Quite simple mathematical formula for calculating perimeter of rectangle.
Let’s program this as Python Code for Finding Perimeter of Rectangle.

# Calculating Perimeter of Rectangle Using Python

x = float(input("Enter Length of Rectangle => "))
y = float(input("Enter Height of Rectangle => "))

# Perimeter of Rectangle
perimeter_of_rectangle = 2 * (x + y)

# Printing out parameter of Rectangle
print("Perimeter of Rectangle is =>", perimeter_of_rectangle)

Output of Above Code

Enter Length of Rectangle => 3
Enter Height of Rectangle => 4
Perimeter of Rectangle is => 14.0

Gagan

Hi, there I'm founder of ComputerScienceHub(Started this to bring useful Computer Science information just at one place). Personally I've been doing JavaScript, Python development since 2015(Been long) - Worked upon couple of Web Development Projects, Did some Data Science stuff using Python. Nowadays primarily I work as Freelance JavaScript Developer(Web Developer) and on side-by-side managing team of Computer Science specialists at ComputerScienceHub.io

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts