Grade & Statistics Analyzer
A menu-driven mini-app that analyzes a class's grades using NumPy: overall statistics, per-subject and per-student breakdowns via the axis= parameter, and boolean masking to identify above/below-average students — all built on top of one 2D NumPy array (rows = students, columns = subjects).
Example run
=== Grade & Statistics Analyzer ===
=== Overall Statistics ===
Mean: 80.27 Median: 84.0 Std: 11.92 Min: 58.0 Max: 95.0
=== Per-Subject Statistics ===
Math: mean=79.8 min=60 max=95
Science: mean=78.8 min=58 max=92
English: mean=82.2 min=70 max=92
=== Per-Student Statistics ===
Ana: mean=86.33 min=79 max=92
Ben: mean=72.67 min=65 max=81
Chidi: mean=91.67 min=89 max=95
Dana: mean=62.67 min=58 max=70
Eli: mean=88.0 min=84 max=92
=== Above-Average Students ===
Ana, Chidi, Eli
=== Below-Average Students ===
Ben, Dana
starter.py below into an empty folder, install NumPy if you haven't already (pip install numpy), then run python3 starter.py.
The pieces
GRADES: a 2D NumPy array, one row per student, one column per subject.overall_stats():.mean()/.std()/.min()/.max()with noaxis=, plusnp.median()— collapsing the whole grid to single numbers.per_subject_stats()/per_student_stats(): the same aggregate functions withaxis=0(per subject/column) andaxis=1(per student/row).above_average_students()/below_average_students(): boolean masking, comparing each student's per-row average against the class-wide average of those averages.format_report(): combines every section into one readable report string.
Ideas to make it your own
- Add a "most consistent student" callout using the lowest per-student
.std()across subjects. - Add a "hardest subject" callout — the subject with the lowest overall mean.
- Load grades from a hardcoded multi-line string, parsed with
.split(), instead of a literal array.
Why this project matters
Nearly every real "analyze this dataset" task — grades, sensor readings, sales figures — follows this exact shape: load numeric data into an array, compute summary statistics, break those statistics down by group, and flag outliers with a condition. This project builds that entire pattern once, on data concrete enough to reason about intuitively.
More project ideas
From Chapter 7 onward, you get a genuine choice of what to build. The Grade & Statistics Analyzer above is fully built out with a starter and reference solution — the four ideas below are not. Each is a real, grounded use case solvable with only what's been taught through Chapter 23. No starter or solution files are provided on purpose — building one of these unassisted is the point.
1 A Weather-Data Averager
Problem: Someone has a week of daily temperature readings for several cities and wants quick summary statistics per city and per day.
What it should do: Store readings as a 2D array (rows = cities, columns = days), and report each city's weekly average (axis=1) and each day's average across all cities (axis=0), plus the single hottest and coldest reading overall.
Suggested approach: This is almost a direct re-skin of this project's grid — swap "student" for "city" and "subject" for "day."
2 A Basic Image-Brightness Adjuster (conceptual)
Problem: A very simple stand-in for image processing — a small 2D array of numbers represents pixel brightness values (0-255), and a program should brighten or darken the whole "image" uniformly.
What it should do: Build a small 2D NumPy array standing in for pixel brightness, then add or subtract a fixed amount from every value (using broadcasting), clipping results to 0-255 with np.clip(). No real image file I/O needed.
Suggested approach: np.clip(arr + amount, 0, 255) is the whole core operation; the rest is printing the before/after grids clearly.
3 A Sports Statistics Tracker
Problem: A coach wants to track several players' stats (points, rebounds, assists) across a season and see who's over/under-performing the team average.
What it should do: Store stats as a 2D array (rows = players, columns = stat categories), report each player's average and each category's team-wide average, and use boolean masking to flag players above the team's average total.
Suggested approach: Directly reuses this chapter's project structure — "player" instead of "student," "stat category" instead of "subject."
4 A Simple Data Normalizer/Scaler
Problem: Raw numeric data (grades on different scales, prices in different currencies) often needs rescaling to a common 0-1 range before further analysis.
What it should do: Given a 1D or 2D array, write normalize(arr) returning (arr - arr.min()) / (arr.max() - arr.min()), mapping the lowest value to 0.0 and the highest to 1.0. Handle the edge case where every value is identical (avoiding a divide-by-zero).
Suggested approach: One vectorized expression using broadcasting throughout — the interesting part is handling the all-identical-values edge case cleanly.