7.6. Functions Calling Functions - 2ΒΆ

Now that we have written and tested distance, we can use it to help write triangle_area. This function will take all six coordinates and return the area.

def triangleArea(x1, y1, x2, y2, x3, y3):
    Do work to calculate area - use distance function to help
    return area

Recall that the formula we need to use is: \(\sqrt{s (s - a) (s - b) (s - c)}\)

The work for this function will involve calling the distance function three times to calculate the lengths of the three sides (a, b, c). We then need to use those to calculate s, the semi-perimeter.

Below is the code for the final program but jumbled up - figure out the right order.

Put the blocks in the right order and indentation. You will use all of the blocks.

You have attempted of activities on this page