Data types · 13 / 29 Exercise Easy

Simple geometric calculator

Objective

Write a Python program that requests the width (x) and height (y) of a rectangle and calculate the perimeter, area and diagonal.

  • Perimeter= sum of the four sides.
  • Area= base x height.
  • Diagonal= Pythagorean theorem.

Input and output format. Read the width and then the height (one per line, with no prompts) and print three lines: Perimeter: …, Area: … and Diagonal: …, each value with 2 decimals.

Input
4
6
Output
Perimeter: 20.00
Area: 24.00
Diagonal: 7.21

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise