Statistics
You're an intern at a rapidly growing tech start-up. They've recently developed a web application for data analysis, and a crucial part of it is calculating statistics. As they've been growing, the application's code base has become quite large, and it's time to start organizing things better. Your task for the week is to create a Python module called statistics_calculator that contains functions to calculate the mean, median, mode, and standard deviation of a list of numbers.
You should structure your code as follows: Create separate files for each of the statistics, with their respective calculation function. These files should be:
mean.py: Contains a functioncalculate_meanto calculate the mean.median.py: Contains a functioncalculate_medianto calculate the median.mode.py: Contains a functioncalculate_modeto calculate the mode (in case there are several most frequent numbers the function should return the smallest one).std_dev.py: Contains a functioncalculate_std_devto calculate the standard deviation.
Each of these files should be within a directory named statistics_calculator. Finally, import all these functions in the statistics_calculator/__init__.py file so that other parts of the application can access these functions without additional imports.
The input and output are handled automatically by the main.py module.
Your code structure should look like this:
statistics_calculator/
├── __init__.py
├── mean.py
├── median.py
├── mode.py
└── std_dev.pyInput | Output |
|---|---|
| 4.0 |
Constraints
Time limit: 2 seconds
Memory limit: 512 MB
Output limit: 1 MB