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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started