Hastening to NumPy
Thomas J. Kennedy
1 The Problem
A common task undertaken by teachers is evaluating exam questions, specifically student performance. While True/False and Multiple Choice questions are usually binary in their results (i.e., either full credit or no credit)… other types of questions are more granular. These types of questions include:
- Essay
- Short Answer
- Multiple Selection (select all that apply)
- Matching
Partial credit is far more abundant on these types of questions (especially essay). When evaluating performance on questions (or groups of questions)… student performance is normally split into categories. Let us use:
- Full Marks - all points were earned
- A - at least 85% of all possible points were earned
- B - at least 70% of all possible points were earned
- C - at least 55% of all possible points were earned
- D - at least 40% of all possible points were earned
- F - Below 40% of all possible points were earned
Since we will have a fairly large data set… multiple sections of a course… across multiple semesters… we will need some NumPy magic for the analysis.
1.1 Input
Data will be located in a text file. Each line will take the form…
[semester code] [crn] [question id] [raw score] [points possible]
where
-
semester code takes the form
YYYYSS
whereYYYY
is the start of the academic year andSS
is the semester code:10
for fall20
for spring30
for summer
-
crn is the Course Reference Number
-
question id is an integer that uniquely identifies a question
-
raw score represents the points earned on a problem
-
points possible represents the number of points possible for a question
1.2 Output
T.B.W.
2 Your Tasks
The input, filtering, and NumPy set up will be handled for you. Your tasks are to implement…
-
A compute percentage function, that given two
np.array
s will compute and store the percent earned.def get_percent_earned(points_earned: np.array, points_possible: np.array) -> np.array:
If you spend a few minutes reviewing the NumPy
np.array
broadcast mechanic… this can be done with a single line. -
A filter to range function that will take an
np.array
, a lower bound (inclusive), and an upper bound (exclusive)… and return annp.array
with all values in that range.def filter_to_range(percent_earned: np.array, lower: float, upper: float) -> np.array:
3 Mechanics
You can run the main program with…
python3.11 compute_statistics.py
The test code can be run with…
python3.11 -m pytest -v tests
4 Files
There are two (2) files in this assignment:
compute_statistics.py
test/test_compute_statistics.py
You will be working in shapes.py
. Do not modify the other files.
You can access the starting files on GitHub. You may either clone the starting repository (through Git) or download a zip file.
5 Grading
Your grade will be based on the following criteria…
- test 000 - code passes
test_get_percent_earned
- test 001 - code passes
test_filter_to_range
5.1 Extra Credit
Note that unlike previous assignments… this one is extra credit (i.e., not required). It is worth 100 points added to your Assignment Total in Canvas.
6 Submitting
You will submit your completed copy of compute_statistics.py
as a file upload through Canvas.
Do not alter any of the other source code files, nor change the module interface.