Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In python Language [20 pts] Write the function rectangle(perimeter, area), which takes two positive integers, perimeter and area. It returns an integer which is the

image text in transcribedIn python Language

[20 pts] Write the function rectangle(perimeter, area), which takes two positive integers, perimeter and area. It returns an integer which is the length of the longest side of a rectangle with integer side lengths w and h which has the given perimeter and area. If no such rectangle exists, it returns None. As a reminder the perimeter of a rectangle with sides w and h is 2w + 2h. The area is w * h. Hint: The built-in function round takes a number as its argument and returns the nearest integer. For example, round(4.0) returns 4, round(4.3) returns 4, and round(4.7) returns 5. Similarly, to do integer division and get an integer result, discarding any fractional result, there is another operator, //, which performs floor division Example: rectangle(14, 10) will return 5 because a 2 x 5 rectangle 5 is the longest side of a rectangle with perimeter 14 and area 10 rectangle(25, 25) will return None because a 2.5 x 10 rectangle does not have integer side lengths

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

Students also viewed these Databases questions

Question

What would you do if the bullies and victim were girls?

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago