A Rectangle is a planar shape which have its opposite sides being equal like a closed shape having sides as 4, 4, 5, 5 with opposite sides being equal will be a Rectangle. Mathematically area of Rectangle can be found by just multiplying it’s sides. For example – If a rectangle have sides a, a, b, b then area of it will be a * b. Quite simple just multiplication.
Let’s Program this as Python Code for Finding Area of Rectangle.
# Finding Area of a Rectangle using Python # Ask User for two sides of Rectangle a = float(input("First Side of Rectangle => ")) b = float(input("Second Side of Rectangle => ")) # Multiply together two sides inputted by user area_of_rectangle = a * b # Printing out area of rectangle print("Area of rectangle is =>", area_of_rectangle)
Output of Above Code
First Side of Rectangle => 4 Second Side of Rectangle => 5 Area of rectangle is => 20.0