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

unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 5

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: , , ,