-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathcomputing-means.py
More file actions
25 lines (21 loc) · 1.04 KB
/
computing-means.py
File metadata and controls
25 lines (21 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'''
Computing means
100xp
The mean of all measurements gives an indication of the typical magnitude of a measurement.
It is computed using np.mean().
Instructions
-Compute the mean petal length of Iris versicolor from Anderson's classic data set.
The variable versicolor_petal_length is provided in your namespace. Assign the mean
to mean_length_vers.
-Hit submit to print the result.
'''
import numpy as np
versicolor_petal_length = np.array([4.7, 4.5, 4.9, 4., 4.6, 4.5, 4.7, 3.3, 4.6, 3.9, 3.5,
4.2, 4., 4.7, 3.6, 4.4, 4.5, 4.1, 4.5, 3.9, 4.8, 4.,
4.9, 4.7, 4.3, 4.4, 4.8, 5., 4.5, 3.5, 3.8, 3.7, 3.9,
5.1, 4.5, 4.5, 4.7, 4.4, 4.1, 4., 4.4, 4.6, 4., 3.3,
4.2, 4.2, 4.2, 4.3, 3., 4.1])
# Compute the mean: mean_length_vers
mean_length_vers = np.mean(versicolor_petal_length)
# Print the result with some nice formatting
print('I. versicolor:', mean_length_vers, 'cm')