"""Area of a parellelogram
The name of this function should be areaParellogram. The function should receive the correct
number of parameters to calculate the area of a parellogram and return this value.
The area of a paralleogram is calculated as the length of the base (b) multiplied by the vertical height (h);
i.e. area of a parellogram = b x h"""
def areaParellogram(b, h):
return b*h
"""Area of a trapezium (trapezoid)
The name of this function should be areaTrapezium. The function should receive the correct number of
parameters to calculate the area of a trapezium and return this value. A trapezium is a 4 sided 2 dimensional
shape with straight lines with a pair of opposite sides parallel. The parallel sides are referred to as
a “bases” (b1 and b2) and the other two sides are referred to as legs. The distance at right angles from
one base to the other is called the altitude (a). The area is calculated as the average of two base
lengths, multiplied by the altitude;
i.e. area of a trapezium (trapezoid) = (b1 + b2) / 2 x a"""
def areaTrapezium(a, b1, b2):
return ((b1 + b2) / 2) * a
"""Area of a triangle
The name of this function should be areaTriangle. The function should receive the correct number of parameters
to calculate the area of a triangle and return this value. The base (b) of a triangle is the distance or length
of the bottom or base and the height (h) of a triangle is the height measured at right angles to the base.
The area of a triangle is measured as half of the base multiplied by the height;
i.e. area of a triangle = 1/2 x b x h"""
def areaTriangle(b, h):
return .5 * b * h
"""Area of a circle
The name of this function should be areaCircleD. The diameter of a circle is any straight line that passes from the
centre of a circle and each endpoint (start and end of the line) are on the circle itself.
Given the diameter of a circle, the function should return the area of circle. The area of a circle, given it’s diameter is
calculated as pi divided by 4 multiplied by the diameter squared (to the power of 2);
i.e. area of a circle, given it’s diameter = (pi / 4) x diameter ^ 2
hint - The python maths module allows you to use a sufficient approximation of pi to 15 decimal places."""
import math
def areaCircleD(diameter):
return (math.pi /4) * diameter * diameter
print("areaParellogram(4, 5) = ", areaParellogram(4, 5))
print("areaTrapezium(4, 4, 5) = ", areaTrapezium(4, 4, 5))
print("areaTriangle(4, 5) = ", areaTriangle(4, 5))
print("areaCircleD(5) = ", areaCircleD(5))