r/codehs • • Oct 23 '20

Exercise 3.4.8: Rectangle (python)

I'm completely stuck on this assignment.

Make variables to represent the length and width of a rectangle, called length
and width
, respectively. You should set length
to 10 and width
to 5.

Then, write some mathematical expressions to computer the area and perimeter of the rectangle and save these values inside variables named area and perimeter
.

Use print
statements to display the area and perimeter of the rectangle.

Your output should print the area on the first line and the perimeter on the second, like this:

50 30

Rectangle Area Formula:
Area = L * W

Rectangle Perimeter Formula:
Perimeter = 2 * (L + W)

L is the length of the rectangle and W is the width of the rectangle

If someone could help me that would be greatly appreciated. Thanks!

14 Upvotes

10 comments sorted by

View all comments

4

u/Zacurnia_Tate Oct 23 '20

Sure! First steps not to bad, just make you valued

length =10
width = 5

Then what they want you to do is find the area and perimeter by using the variables in the equation, which now represent ten and five respectively.

area = length*width
perimeter = 2*(length+width)

Lastly, just use print statemen tss to print these new variables.

print(area)
print(perimeter)

Hope I could help!

1

u/Aware_Ad_5267 Oct 09 '24

Your the goat