Computing Areas

Write a function area(type, a, b) that receives a string type (which may
be "rectangle", "triangle", or "circle") and two real numbers a and b,
and computes the area of the given shape.

- If type is "rectangle", a and b are the width and height of the
  rectangle, respectively.

- If type is "triangle", a and b are the base and height of the
  triangle, respectively.

- If type is "circle", a is the radius of the circle, and b 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__":

Observation

To get the value of π, add a line with ’import math’ at the top of your
file, and then use math.pi when needed.

Problem information

Author: ProAl1 professors

Generation: 2026-01-25T17:01:58.817Z

© Jutge.org, 2006–2026.
https://jutge.org
