Assignment 1

Part 1: Files, Git, GitHub

Use JupyterLab to launch a terminal and use the terminal to do the following tasks:

  1. Create a new directory called resume within your home directory
  2. Create an empty file within this directory called Readme.md

Now use JupyterLab to edit the file:

  1. Navigate to the directory in the file browser
  2. Open Readme.md in the text editor
  3. Open Readme.md in in Markdown Preview
  4. Arrange these files side-by-side so you can see your document rendered
  5. Edit the file in the editor. Add the following information:

    1. Top level heading with your name
    2. An image. It can be a photo of you or, if you prefer, a photo of your spirit animal.
    3. Secondary heading entitled "Education"
    4. A list of schools you attended, hyperlinked to the websites of those insitutions
  6. Save the file

Now go back to the terminal and do the following:

  1. Initialize a new git repository in the resume directory
  2. Add the Readme.md file to the repository
  3. Create a new commit with a commit message
  4. Check the git log to see your commit history
  5. Go to github and create a new public repository entitled resume
  6. Push your local resume repository to GitHub following the instructions.
  7. View your online resume at http://github.com//resume

Finally, go back to the editor and add a new subsection called "Research Interests" to your Readme.md file. Update your local git repository and push your changes to GitHub. Verify that the remote repository is updated.

To "hand in" this part of the assignment, just provide the link to your repository in the notebook cell below.

Create your Assignments Repository

Now that you know how to create a git repository, you should create your assignments repository.

  • Create a new directory called rces-assignments in your home directory.
  • Copy the first assignment template into this directory (you will have to repeat this step each time a new assignment comes out.)

      cp examples/content/Assignments/assignment_1.ipynb rces-assignments/
  • Initialize a new git repository
  • Add the file and make your first commit
  • Create a new private repository on GitHub called rces-assignments. (Call it exactly like that. Do not vary the spelling, capitalization, or punctuation.)
  • Push your rces-assignments repository to github
  • On github, go to "settings" -> "collaborators" and add rabernat and xjin49
  • Push new commits to this repository whenever you are ready to hand in your assignments

Part 2: Lists and Loops

In this problem, we will explore the basic data structures and flow controls of python by manually parsing a CSV file.

Note that this is a futile exercise. In the "real world" you should never manually parse a CSV file. There are utilities out there that will do it for you much more quickly and efficiently. However, it is a useful exercise for learning python.

First we need to download a data file to parse. We can do this from the terminal, OR we can use ! to run shell commands directly from the notebook. However you do it, you need to run these commands:

wget https://tinyurl.com/rces-roster
mv rces-roster rces-roster.csv

Before starting the python part, use the JupyterLab file browser to browse to this file. Click to open it. What do you see?

Now we will begin the process of reading the file with python

Open the file using the open function

Specifically, run the command

file = open('rces-roster.csv')
In [ ]:
 

Use the help function to get the documentation for your new variable file

This will produce a long list of methods you can use with file.

In [ ]:
 

Read the lines of the file into a variable called lines

Hint: use the documentation above to find the method that sounds most likely to do what you want.

In [ ]:
 

What type of object is lines?

In [ ]:
 

It should be a familiar type we learned about in class.

Display lines at the end of a cell in order to see its contents

In [ ]:
 

Use slicing to display the first three items of the list. And the last 3

In [ ]:
 
In [ ]:
 

Create a new list called data that does not contain the header row

In [ ]:
 

Now iterate through lines and print the item if it contains your uni

In [ ]:
 

By now you have figured out what is in this data. Let's now transform it into a more useful format.

Write code to transform the data into a dictionary whose keys are UNIs and whose values are full names.

(You might need to review Python's string methods.)

In [ ]:
 

Use this dictionary to look up your own name using your uni

In [ ]:
 

Figure out who has the longest last name in the class

In [ ]:
 
In [ ]:
 
In [ ]:
 
In [ ]: