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.py
file should include functions to calculate the area and perimeter of a circle. The function to calculate the area should be namedcalculate_circle_area
and take the radius as an argument. The function to calculate the perimeter (also known as the circumference) should be namedcalculate_circle_perimeter
and take the radius as an argument.
- The
square.py
file should include functions to calculate the area and perimeter of a square. The function to calculate the area should be namedcalculate_square_area
and take the side length as an argument. The function to calculate the perimeter should be namedcalculate_square_perimeter
and take the side length as an argument.
- The
rectangle.py
file should include functions to calculate the area and perimeter of a rectangle. The function to calculate the area should be namedcalculate_rectangle_area
and take the length and width as arguments. The function to calculate the perimeter should be namedcalculate_rectangle_perimeter
and take the length and width as arguments.
- The
triangle.py
file should include functions to calculate the area and perimeter of a triangle. The function to calculate the area should be namedcalculate_triangle_area
and take the base and height as arguments. The function to calculate the perimeter should be namedcalculate_triangle_perimeter
and 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 |
print(calculate_circle_area(10)); print(calculate_square_perimeter(5)) | 314.16
20 |
print(calculate_rectangle_area(4, 7)); print(calculate_triangle_perimeter(3, 4, 5)) | 28
12 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB