Python Program to Print Area and Circumference of Rectangle

 
Currently at: News Home > Python Program to Print Area and Circumference of Rectangle
 

Deepthi Sharma wrote on 7/26/2021 10:12:24 AM in MCA-1st Sem Assignment | Read 1060 times.
Featured Image for the Article

Question:

Write a program that prompts the user to input the length and the width of a rectangle and outputs the area and circumference of the rectangle.

The Formula is:
AREA = LENGTH * WIDTH
CIRCUMFERENCE = 2 (LENGTH + WIDTH)

Answer: 

# Write a program that prompts the user to input the length and the width of a rectangle and
# outputs the area and circumference of the rectangle. The Formula is:
# AREA = LENGTH * WIDTH
# CIRCUMFERENCE = 2 (LENGTH + WIDTH)

def AreaOfRectangle(length, width):
    print("Area of Rectangle with Length:",length,"and width:",width,"is:", length*width)

def CircumferenceOfRectanble(length,width):
    circumference = 2*(length+width)
    print("Circumference",circumference)

length1 = int(input("Enter the length of Rectangle:\n " ))
width1 = int(input("Enter the width of Rectangle:\n " ))

AreaOfRectangle(length1,width1)

CircumferenceOfRectanble(length1,width1)

Python-Area-Circumference-of-Rectangle

Output of the Code

Python-Area-Circumference-of-Rectangle-Output

Thanks for reading. If you have difficulty running this code, please leave a comment and let us know. 

Site Search

Advertisement