To find the area of a rectangle or a square you need to multiply the length and the width of a rectangle or a square.
In this example we’ll calculate the area and perimeter of a rectangle in Python3.
Python Code:
1 2 3 4 5 6 7 8 | width=input('Please write the width of your rectangle: ') length=input('Please write the length of your rectangle: : ') area=int(width)*int(length) perimeter=2*(int(width)+int(length)) print("Area : {0}".format(area)) print("Perimeter : {0}".format(perimeter)) |
Output: