Skip to content

Commit 4a7d131

Browse files
Create README.md
1 parent c0387c8 commit 4a7d131

File tree

1 file changed

+45
-0
lines changed
  • Mean-Variance-Standard Deviation Calculator

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
### Assignment
2+
3+
Create a function named `calculate()` in `mean_var_std.py` that uses Numpy to output the mean, variance, standard deviation, max, min, and sum of the rows, columns, and elements in a 3 x 3 matrix.
4+
5+
The input of the function should be a list containing 9 digits. The function should convert the list into a 3 x 3 Numpy array, and then return a dictionary containing the mean, variance, standard deviation, max, min, and sum along both axes and for the flattened matrix.
6+
7+
The returned dictionary should follow this format:
8+
```py
9+
{
10+
'mean': [axis1, axis2, flattened],
11+
'variance': [axis1, axis2, flattened],
12+
'standard deviation': [axis1, axis2, flattened],
13+
'max': [axis1, axis2, flattened],
14+
'min': [axis1, axis2, flattened],
15+
'sum': [axis1, axis2, flattened]
16+
}
17+
```
18+
19+
If a list containing less than 9 elements is passed into the function, it should raise a `ValueError` exception with the message: "List must contain nine numbers." The values in the returned dictionary should be lists and not Numpy arrays.
20+
21+
For example, `calculate([0,1,2,3,4,5,6,7,8])` should return:
22+
```py
23+
{
24+
'mean': [[3.0, 4.0, 5.0], [1.0, 4.0, 7.0], 4.0],
25+
'variance': [[6.0, 6.0, 6.0], [0.6666666666666666, 0.6666666666666666, 0.6666666666666666], 6.666666666666667],
26+
'standard deviation': [[2.449489742783178, 2.449489742783178, 2.449489742783178], [0.816496580927726, 0.816496580927726, 0.816496580927726], 2.581988897471611],
27+
'max': [[6, 7, 8], [2, 5, 8], 8],
28+
'min': [[0, 1, 2], [0, 3, 6], 0],
29+
'sum': [[9, 12, 15], [3, 12, 21], 36]
30+
}
31+
```
32+
33+
The unit tests for this project are in `test_module.py`.
34+
35+
### Development
36+
37+
For development, you can use `main.py` to test your `calculate()` function. Click the "run" button and `main.py` will run.
38+
39+
### Testing
40+
41+
We imported the tests from `test_module.py` to `main.py` for your convenience. The tests will run automatically whenever you hit the "run" button.
42+
43+
### Submitting
44+
45+
Copy your project's URL and submit it to freeCodeCamp.

0 commit comments

Comments
 (0)