A rectangle has width w and height h. Print its area on the first line and its perimeter on the second.
What to build
A program that works out two values from the same two inputs.
Requirements
- Read the width and the height as whole numbers.
- Print the area first, then the perimeter.
Input
Two lines: w, then h. Both are whole numbers from 1 to 10000.
Output
Two lines: the area w * h, then the perimeter 2 * (w + h).
Constraints
Both numbers are from 1 to 10000.
Example
Input:
4
3
Output:
12
14
Why it works
Each formula is a short expression. Python works out each one from the same two variables.
Examples
Example 1 · Input
4 3
Expected output
12 14
Example 2 · Input
1 1
Expected output
1 4
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
Each print() call writes one line.
Solution
Show one correct solution (try it yourself first)
w = int(input()) h = int(input()) print(w * h) print(2 * (w + h))