(Area and perimeter of a rectangle) Write a program that displays the area and perimeter of a rectangle with the width of 4.5 and height of 7.9 using the following formula:
area = width * height
Code:
#Calculate the area of rectangle with the width and height
area = 4.5 * 7.9
#Calculate the perimeter of rectangle with the width and height
perimeter = (2 * 4.5) + (2 * 7.9)
#display the area
print("area of rectangle:", area)
#display the perimeter
print("perimeter of rectangle:", perimeter)
Output:
Python 3.2.1 (default, Jul 10 2011, 21:51:15) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
area of rectangle: 35.550000000000004
perimeter of rectangle: 24.8
>>>