# !cat page3.csvPage 3 Results
Page 3
In [1]:
In [2]:
# !shuf --output=page3.csv <page3.csvIn [3]:
# !cat page3.csvSince I ran this notebook more than once, the initial CSV is now completely lost…
Per-question results
Question 0 - preparing data
We will be reading the data here, and processing later..
In [1]:
import csv
import numpy as np
results = []
with open('page3.csv') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",")
for row in csv_reader:
results.append(list(map(int, row)))
res_array = np.array(results)In [2]:
import matplotlib.pyplot as plt
def print_stats(A, bins = [x + 0.1 for x in range(-1,6)]):
print(f"Results: {A.tolist()}")
print(f"Mean: {np.mean(A)}")
print(f"Median: {np.median(A)}")
vals, counts = np.unique(A, return_counts=True)
print(f"Mode: {vals[np.argmax(counts)]} With count: {counts[np.argmax(counts)]}")
plt.hist(A, bins = bins, align='right')In [3]:
print_stats(res_array[:,:1])Results: [[5], [5], [5], [4], [5], [5], [3], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [5], [4], [5], [5], [5], [5], [4], [1], [5], [5], [5], [5], [5], [5], [5]]
Mean: 4.71875
Median: 5.0
Mode: 5 With count: 27

In [4]:
print_stats(res_array[:,1:2])Results: [[5], [5], [5], [5], [4], [5], [1], [5], [5], [5], [5], [4], [5], [5], [5], [5], [4], [5], [3], [4], [3], [5], [5], [4], [1], [4], [4], [4], [5], [4], [5], [5]]
Mean: 4.34375
Median: 5.0
Mode: 5 With count: 19

In [5]:
print_stats(res_array[:,2:3], bins = [x + 0.1 for x in range(-1, 11)])Results: [[5], [10], [5], [5], [5], [10], [2], [8], [5], [10], [8], [10], [8], [10], [10], [10], [5], [5], [10], [5], [7], [10], [5], [5], [0], [10], [10], [10], [10], [3], [10], [10]]
Mean: 7.375
Median: 8.0
Mode: 10 With count: 15

In [6]:
print_stats(res_array, [x + 0.1 for x in range(-1, 11)])Results: [[5, 5, 5], [5, 5, 10], [5, 5, 5], [4, 5, 5], [5, 4, 5], [5, 5, 10], [3, 1, 2], [5, 5, 8], [5, 5, 5], [5, 5, 10], [5, 5, 8], [5, 4, 10], [5, 5, 8], [5, 5, 10], [5, 5, 10], [5, 5, 10], [5, 4, 5], [5, 5, 5], [4, 3, 10], [5, 4, 5], [5, 3, 7], [5, 5, 10], [5, 5, 5], [4, 4, 5], [1, 1, 0], [5, 4, 10], [5, 4, 10], [5, 4, 10], [5, 5, 10], [5, 4, 3], [5, 5, 10], [5, 5, 10]]
Mean: 5.479166666666667
Median: 5.0
Mode: 5 With count: 56
In [7]:
In [8]:
f = lambda x: x + (20 - x) / 2
print_stats(f(np.sum(res_array, axis=1)), bins = [x + 0.1 for x in range(9,21)])Results: [17.5, 20.0, 17.5, 17.0, 17.0, 20.0, 13.0, 19.0, 17.5, 20.0, 19.0, 19.5, 19.0, 20.0, 20.0, 20.0, 17.0, 17.5, 18.5, 17.0, 17.5, 20.0, 17.5, 16.5, 11.0, 19.5, 19.5, 19.5, 20.0, 16.0, 20.0, 20.0]
Mean: 18.21875
Median: 19.0
Mode: 20.0 With count: 10