Area Calculator

For this challenge we are going to use a Python script to calculate the area in square meters of two different flats.

To do so we will write a computer program that will add up all the areas of each room.

Most rooms have a rectangle shape. So we will first define a function that takes two parameters: width and length and return the area of the rectangle using the following formula:

area = width * length

Let’s use this formula to calculate the area of this small flat:Flat_0

Your Challenge


Tweak the code above to calculate the area of the following two flats: (Click on each picture to zoom in).
Flat_1

Flat_2

Challenge #2


The area of a right-angled triangle can be calculated as follows:
triangle
area = width * length / 2

Add a new function called getTriangleArea to return the area of a right-angled triangle using two parameters: width and length.

Use both the getRectangleArea and getTriangleArea functions to calculate the area of this room:
flat_4

Challenge #3:


Use your code to calculate the area of this small mansion (Click on picture to zoom in):
flat_5

Share Button
Posted in Computer Science, Python - Beginner, Python Challenges Tagged with: , , ,

Our Latest Book

Follow this blog