Question: Implement rect, which takes two positive integer arguments, perimeter and area. It returns the integer length of the longest side of a rectangle with integer

Implement rect, which takes two positive integer arguments, perimeter and area. It returns the integer length of the longest side of a rectangle with integer side lengths l and h which has the given permeter and area. If no such rectangle exists, it returns False.

The perimeter of a rectangle with sides la nd h is 2l+2h. The area is l*h

The built in function round takes a number as its argument and returns the nearest integer. For example, round 2.0 evaluates to 2, and round(2.5) evaluates to 3.

def rect(area,perimeter):

>>>rect(10,14) # A 2x5 rectangle

5

>>>rect(5,12)

5

>>>rect(25,20) #5x5 rectangle

5

>>>rect(25,25)# A 2.5x10 rectangle doesnt count because sides are not integers

False

>>>rect(25,29) # A 2x12.5 rectangle doesnt count because sides are not integers

False

>>> rect(100,50) # A 5x20 rectangle

20

side=1

while side*side ??? area:

other=round(???)

if ???:

???

side=side+1

return False

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!