Day 1 Homework: Python - Lists and For Loops

For this assignment, we will be working with inflammation-01.csv, a simulated dataset representing the response of arthritis patients to a new drug. The data is sourced from here.

In this dataset, each row represents a different patient. Each column represents a different day. Each element in the dataset is the number of arthritis flare-ups that a patient has in a given day.

For each exercise, please submit your code along with your answer. You can have one script per exercise, or have all exercises together in one larger script – either way is fine. Since we haven’t yet learned how to write to a file in Python, it is ok to print out your answers and then manually copy them over to a text file.

You will submit your assignments tomorrow through Git, after you create a GitHub account overnight and we set it up in the morning.

Exercise 1: Reading in Data

Print the number of flare-ups that the fifth patient had on the first, tenth, and last day.

Exercise 2: Caluclating Averages

For each patient, calculate the average number of flare-ups per day. Print the average values for the first 10 patients.

These are the row averages - for example, patient 1 has 5.45 flare-ups per day on average; patient 2 has 5.425 flare-ups per day on average.

Exercise 3: Finding Maximum and Minimum Values

Using the average flare-ups per day calculated in part 2, print the highest and lowest average number of flare-ups per day.

Exercise 4: Differences Between Patients

For each day, print the difference in number of flare-ups between patients 1 and 5.

Optional Exercise:

For each day, find the average number of flare-ups across all patients (i.e. the column averages). What is the highest average number of flare-ups per day?

Creating a GitHub account

Please do the following before the start of class tomorrow. Create a GitHub account using the following instructions:

  1. Go to github.com and click the Sign up button on the upper right hand corner.
  2. Follow the prompts to enter your email (use your @jhu.edu email) and create a password and username.
  3. Email or Slack yourself the GitHub username so that you can refer to it later.
  4. GitHub will prompt you for a launch code that they’ve sent to you by email. Open your email and paste in the launch code.

Grading:

  • Exercise 1:
    • 1 pt. Printed out first and last days
  • Exercise 2:
    • 1 pt. Calculate averages for all patients
    • 1 pt. Printed out first 10 averages
  • Exercise 3:
    • 1 pt. Printed out maximum
    • 1 pt. Printed out minimum
  • Exercise 4:
    • 1 pt. Printed out differences between patients