The bin for a score on an edge
Predict the output · Medium · §8.2 Histogram bins
The code counts 10 exam scores in bins that are 10 points wide, starting at 50. Predict the two lines of output without running the code.
Code
import numpy as np
scores = [45, 58, 60, 65, 70, 70, 79, 80, 88, 90]
edges = [50, 60, 70, 80, 90]
counts, _ = np.histogram(scores, bins=edges)
print(counts.tolist())
print(int(counts.sum()), len(scores))Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.