A Python project for freeCodeCamp's Data Analysis with Python certification.
This project uses NumPy to compute the mean, variance, standard deviation, max, min, and sum of rows, columns, and elements of a 3x3 matrix from a 9-element list.
calculate([0, 1, 2, 3, 4, 5, 6, 7, 8]){
'mean': [[axis0], [axis1], flattened],
'variance': [[axis0], [axis1], flattened],
'standard deviation': [[axis0], [axis1], flattened],
'max': [[axis0], [axis1], flattened],
'min': [[axis0], [axis1], flattened],
'sum': [[axis0], [axis1], flattened]
}- axis0 → column-wise (top to bottom)
- axis1 → row-wise (left to right)
- flattened → entire matrix
If fewer than 9 elements are passed, raises:
ValueError: List must contain nine numbers.
| File | Purpose |
|---|---|
mean_var_std.py |
Core calculate() function |
main.py |
Manual test runner |
test_module.py |
Unit tests |
requirements.txt |
Dependencies |
# 1. Clone the repo
git clone https://github.com/YOUR_USERNAME/mean-variance-std-calculator.git
cd mean-variance-std-calculator
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run the main file
python3 main.py
# 4. Run unit tests
python3 -m unittest test_module.py -vcalculate([0,1,2,3,4,5,6,7,8])
# Returns:
{
'mean': [[3.0, 4.0, 5.0], [1.0, 4.0, 7.0], 4.0],
'variance': [[6.0, 6.0, 6.0], [0.667, 0.667, 0.667], 6.667],
'standard deviation': [[2.449, 2.449, 2.449], [0.816, 0.816, 0.816], 2.582],
'max': [[6, 7, 8], [2, 5, 8], 8],
'min': [[0, 1, 2], [0, 3, 6], 0],
'sum': [[9, 12, 15], [3, 12, 21], 36]
}- Python 3
- NumPy
MIT