Hastening to NumPy

Thomas J. Kennedy

Contents:

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:

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:

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

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…

  1. A compute percentage function, that given two np.arrays 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.

  2. A filter to range function that will take an np.array, a lower bound (inclusive), and an upper bound (exclusive)… and return an np.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:

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…

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.