Rectangle Area and Perimeter Together

Easy ⏱ 8 min 77% acceptance ★★★★★ 4.7
Write a function rectangle_stats(length, width) that returns a tuple (area, perimeter) for a rectangle with the given length and width.

Examples

Example 1
Input
rectangle_stats(4, 5)
Output
(20, 18)
Explanation

area = 4*5 = 20, perimeter = 2*(4+5) = 18.

Constraints

  • length and width are positive numbers.

Topics

Functionsmultiple return values

Companies

GoogleWipro

Hints

Hint 1

Python lets you return several values separated by commas; they are packed into a tuple.

Hint 2

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

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.