Geometric Operations
You are the new lead developer at PyGeo Inc., a company specializing in building software tools for architects and builders. They need a module for their latest software that calculates the area and perimeter of various geometrical shapes, including circles, squares, rectangles, and triangles.
The new module should be named geometry_operations and should include functions to calculate the area and perimeter for each shape. To keep the code organized and scalable for future additions, each shape should be defined in a separate file.
There's a catch: the architects and builders will input data through a separate module main.py, and the output will also be handled automatically by this module. You are only responsible for the calculations and returning the results:
The
circle.pyfile should include functions to calculate the area and perimeter of a circle. The function to calculate the area should be namedcalculate_circle_areaand take the radius as an argument. The function to calculate the perimeter (also known as the circumference) should be namedcalculate_circle_perimeterand take the radius as an argument.The
square.pyfile should include functions to calculate the area and perimeter of a square. The function to calculate the area should be namedcalculate_square_areaand take the side length as an argument. The function to calculate the perimeter should be namedcalculate_square_perimeterand take the side length as an argument.The
rectangle.pyfile should include functions to calculate the area and perimeter of a rectangle. The function to calculate the area should be namedcalculate_rectangle_areaand take the length and width as arguments. The function to calculate the perimeter should be namedcalculate_rectangle_perimeterand take the length and width as arguments.The
triangle.pyfile should include functions to calculate the area and perimeter of a triangle. The function to calculate the area should be namedcalculate_triangle_areaand take the base and height as arguments. The function to calculate the perimeter should be namedcalculate_triangle_perimeterand take the lengths of the three sides as arguments.
Import all the functions from all the files inside geometry_operations/__init__.py file to make it accessible from the main.py without any additional imports.
Note: You can assume that all inputs are valid, i.e., positive numbers.
Input | Output |
|---|---|
| 314.16 |
| 28 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB