220k views
18 votes
Draw a rectangle, give its perimeter and Area

Ask the user for a length and width of a rectangle.
Draw the rectangle
find and show the perimeter
find and show the Area

1 Answer

8 votes

I am assuming this is in python, so I will use comments to explain each step

l=int(input('What is the length of the rectangle')

w=int(input('What is the width of the rectangle')

#here use whatever graphics code required to draw the rectangle

#will probably be similar to rect=Rectangle(l,w)

print('Perimeter is' +(2*l+2*w))

print('Area is' +(l*w))

User Changaco
by
7.4k points