Write a function that receives a string (which may be "rectangle", "triangle", or "circle") and two real numbers and , and computes the area of the given shape.
If is "rectangle", and are the width and height of the rectangle, respectively.
If is "triangle", and are the base and height of the triangle, respectively.
If is "circle", is the radius of the circle, and is ignored.
Important: Only the function is expected. If you
submission includes a main program, it has to be either commented out,
or under the condition if __name__ == "__main__":
To get the value of
,
add a line with ’import math’ at the top of your file, and
then use math.pi when needed.
>>> area('rectangle', 3.1, 4.0) 12.4 >>> area('triangle', 6.0, 2.0) 6.0 >>> area('rectangle', 8.2, 8.2) 67.24 >>> area('circle', 1.0, 0.0) 3.141592653589793