Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mean-Variance-Standard Deviation Calculator

A Python project for freeCodeCamp's Data Analysis with Python certification.

Project Description

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.

Function

calculate([0, 1, 2, 3, 4, 5, 6, 7, 8])

Returns

{
  '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.

Files

File Purpose
mean_var_std.py Core calculate() function
main.py Manual test runner
test_module.py Unit tests
requirements.txt Dependencies

Setup & Run

# 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 -v

Example Output

calculate([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]
}

Technologies Used

  • Python 3
  • NumPy

License

MIT

About

freeCodeCamp Data Analysis with Python - Project 1

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages