This first lab will be a "warmup," intended to refresh your memory of the Python programming language, as well as to familiarize you with several libraries and tools we will be using this semester.
For this lab you will work individually.
We will be using GIT for all labs; if you need a refresher, check https://www.cs.swarthmore.edu/git/
Do the following steps to get the starting point code. Replace USERNAME with your own username. The $ represents the command prompt.
For this lab, we'll be using a development environment called Jupyter. The primary advantage of this platform is that it provides "notebooks," which are a way of interweaving Python code segments and their output with descriptive text, equations, graphs, and more.
Like any tool, Jupyter has its advantages and disadvantages, and we won't be using it for every lab this semester, but it's an excellent fit for the goals of this warmup lab.
To run Juypter on one of our CS machines, you just need to do the following:
The first command configures the Python environment so you'll have access to all the packages that we'll be using this semester; it needs to be run once (in any given terminal) before jupyter-lab. If you forget to do this, then jupyter-lab likely won't launch at all; if you get a command not found error, it's probably because you forgot to source the correct Python virtual environment.
The source command should actually change your command prompt, putting a (CS63env) in the front; this is a reminder that it's worked correctly, and you can run Jupyter.
When you run jupyter-lab, it should launch a web browser (or open a tab in an existing browser window). There should be a file browser in the panel on the left; the root directory will be whatever directory you ran the jupyter-lab command in (if you followed the directions above, this should be your cs63 directory). Navigate to the Lab 0 directory and double click on the file named python_warmup.ipynb; doing so should open the notebook in the large panel on the right.
From here, all the remaining instructions are in the notebook; start reading at the top, and follow the directions in the notebook.
When you're finished, you can quit Jupyter by clicking the "File" menu and selecting "Shut Down" at the bottom. Alternatively, if you type [Ctrl-c] twice in the terminal you ran the command in, that will also shut down the program.
Note that if you want the (cs63-s24) to go away, you can deactivate the virtual environment:
$ deactivateHowever, this is not strictly necessary, since the virtual environment really only effects the versions of Python and Python libraries; all other commands should work normally regardless of whether you are in the CS63 environment or not.
When you're done, be sure to remember to use GIT to add/commit/push the changes you've made!
If you want to run Jupyter remotely (i.e. over an SSH connection, as opposed to on a machine you're physically logged in to), you'll need to add a couple of extra steps to the normal process. This is because Jupyter Lab is actually running a web server that your browser connects to; if the server and the browser are on the same machine, this happens automatically, but if you're connecting remotely you need to tell the two machines how to connect your local browser to the remote server.
The steps for running Jupyter remotely are as follows:
To access the server, open this file in a browser: file:///home/mitchell/.local/share/jupyter/runtime/jpserver-581164-open.html Or copy and paste one of these URLs: http://localhost:6311/lab?token=833c29214af009d97714c2a852333e47cb8a954dba7d9e7d or http://127.0.0.1:6311/lab?token=833c29214af009d97714c2a852333e47cb8a954dba7d9e7dThe details will vary slightly (i.e. you won't have the same port and token number).