In Exercise 05, you will write a utility class for working with a column of numerical values. This will give practice with constructors, methods, operator overloading and more. In the process, you will develop a keen understanding for the intuition and abstractions provided by a highly popular and valuable to understand library called
NumPy. We will explore NumPy later in the course!
In this exercise, you will build-up an abstraction, with many powerful capabilities, in the form of a class called
Due Wednesday 4/21 at 11:59pm - Start Early!
0. Pull the skeleton code
You will find the starter files needed by “pulling” from the course workspace repository. Before beginning, be sure to:
- Be sure you are in your course workspace. Open the file explorer and you should see your work for the course. If you do not, open your course workspace through File > Open Recent.
- Open the Source Control View by clicking the 3-node (circles) graph (connected by lines) icon in your sidebar or opening the command palatte and searching for Source Control.
- Click the Ellipses in the Source Control pane and select “Pull, Push” from the drop-down menu, then select “Pull from…” A box will appear and you should select either “origin” or “upstream”, but not “backup”. This will begin the pulling process from the course repository. It should silently succeed. (If you are on macOS and do not see anything in source control anymore, it may be because of a macOS update. You can typically resolve this by opening a new Terminal, typing the command
xcode-select --install, pressing enter and following its instructions.) You will also need to restart VSCode after doing this.
- Return to the File Explorer pane and open the
exercisesdirectory. You should see it now contains the directory named
ex05. If you expand that directory, you will see the starter files:
1. Starter Files
Your work in this exercise will be completed across two files:
Simpy.py- This is the Python module where your
Simpyclass is implemented.
SimpyDemos.ipynb- This is the Jupyter Notebook file that walks you through each of the methods of
Simpyand provides sample uses. There are additionally a few check for understanding cells that will ask you to solve problems in terms of methods you previously implemented.
The descriptions of the functions you will need to implement, as well as example code that makes use of those functions once they are correctly implemented, can be found in the
If your screen is large enough, you are encouraged to open these files side-by-side in VSCode by dragging the tab of one to the right side of VSCode so that it changes to a split pane view. Closing your file explorer can help give you additional horizontal space.
Be sure to save your work in
Simpy.py before reevaluating cells in
SimpyDemos.ipynb. Sometimes the Jupyter Notebook can reach a bad state and the only way to fix is to close your
ipynb tab and reopen a new one, thus restarting the kernel.
If there are corrections or clarifications needed to the instructions in the
ipynb file, they will post in this section.
Login to Gradescope and select the assignment named "EX05 - Simpy. You’ll see an area to upload a zip file. To produce a zip file for autograding, return back to Visual Studio Code.
If you do not see a Terminal at the bottom of your screen, open the Command Palette and search for “View: Toggle Integrated Terminal”.
To produce a zip file for
ex05, type the following command (all on a single line):
python -m tools.submission exercises/ex05
In the file explorer pane, look to find the zip file named “21.mm.dd-hh.mm-exercises-ex05.zip”. The “mm”, “dd”, and so on, are timestamps with the current month, day, hour, minute. If you right click on this file and select “Reveal in File Explorer” on Windows or “Reveal in Finder” on Mac, the zip file’s location on your computer will open. Upload this file to Gradescope to submit your work for this exercise.
Autograding will take a few moments to complete. For this exercise there will be 15 points manually graded for the
Checks for Understanding cells in the notebook being completed. If there are issues reported, you are encouraged to try and resolve them and resubmit. If for any reason you aren’t receiving full credit and aren’t sure what to try next, come give us a visit in office hours!