Challenge: Rectangle Calculator
Completed
Read the length and width of a rectangle and print its area and perimeter.
Area = length × width. Perimeter = 2 × (length + width).
Input
Line 1: the length. Line 2: the width. Both are whole numbers.
Output
Area: <area> Perimeter: <perimeter>
Example
Input
5 3
Output
Area: 15 Perimeter: 16
Editor
Python
Hints
Convert both inputs with int().
Brackets matter: 2 * (length + width).
Solution explanation
Read both numbers with int(input()), then use brackets so the sum happens before multiplying by 2.
Show solution
length = int(input())
width = int(input())
print("Area:", length * width)
print("Perimeter:", 2 * (length + width))