Exercise: rectangle perimeter
Write a function perimeter(width, height) that returns the perimeter of a rectangle with sides width and height. The perimeter is the sum of the lengths of all four sides.
perimeter(3, 5)→16perimeter(1, 1)→4perimeter(0, 7)→14
Constraints: the sides are integers from 0 to 1000, and either of them may be zero.
The "Run tests" button runs the checks from the test_rectangle.py tab—you can read them but not change them. Each check is a test_… function: it calls perimeter, and the line with assert demands that the answer equal the expected one. If it does not, the check shows got and what your function returned.
None in the stub means "nothing yet"—replace the whole return None line.
Do not add extra imports unless the task says so explicitly.
Subscribe to take the course
The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.