Skip to content
Snippets Groups Projects
Commit 8048f0bd authored by Ashwin Maran's avatar Ashwin Maran
Browse files

add lab-p5 and p5

parent 48b8afc6
No related branches found
No related tags found
No related merge requests found
# Lab P5: Looping Patterns and Hurricane API
Let us start Lab-P5! This lab introduces you to some fundamental looping patterns that will help solve P5. It is
designed to help you become comfortable using the functions in `project.py`. You will also
learn basic methods to manipulate strings needed for P5.
## Corrections and clarifications
None yet.
**Find any issues?** Report to us:
- Ashwin Maran <amaran@wisc.edu>
----------------------------------
## Learning Objectives:
In this lab you will practice:
- inspecting the `project.py` file,
- iterating through data using a `for` loop,
- writing algorithms to search, filter, count, and find min / max,
- writing algorithms that store/use indices
- writing helper functions,
- writing algorithms that manipulate strings.
----------------------------------
## Introduction:
In this lab, you will look at hurricane data and learn techniques to extract specific data. Data
scientists use such data when studying the effects of climate change.
According to the [Center for Climate and Energy Solutions](https://www.c2es.org/content/hurricanes-and-climate-change/),
"Climate change is worsening
hurricane impacts in the United States by increasing the intensity and decreasing the speed at
which they travel. Scientists are currently uncertain whether there will be a change in the number
of hurricanes, but they are certain that the intensity and severity of hurricanes will continue to
increase. These trends make hurricanes far more costly in terms of physical damage and deaths."
By tracking past hurricanes' speed, number of fatalities, and property damage, scientists can prepare for
future ones.
------------------------------
## Note on Academic Misconduct
You may do these lab exercises only with your project partner; you are not allowed to start working on Lab-P5 with one person, then do the project with a different partner. Now may be a good time to review [our course policies](https://cs220.cs.wisc.edu/f23/syllabus.html).
------------------------------
## Project partner
We strongly recommend students find a project partner. Pair programming is a great way to learn from a fellow student. Project difficulty increases exponentially in this course. Finding a project partner early on during the semester is a good idea.
If you are still looking for a project partner, take a moment now to ask around the room if anyone would like to partner with you on this project. Then you can work with them on this lab as well as the project.
----------------------------------
## Segment 1: Setup
Create a `lab-p5` directory and download the following files into the `lab-p5` directory:
* `hurricanes.csv`
* `project.py`
* `lab-p5.ipynb`
* `public_tests.py`
Once you have downloaded the files, open a terminal and navigate to your `lab-p5` directory.
Run `ls` to make sure the above files are available.
**Note:** If you accidentally downloaded the file as a `.txt` instead of `.csv` (or `.cvs` or `.csv.txt`)
(say `hurricanes.cvs`), you can execute `mv hurricanes.cvs hurricanes.csv` on a
Terminal/PowerShell window. Recall that the `mv` (move) command lets you rename a source file
(first argument, example: `hurricanes.cvs`) to the destination file (second argument, example:
`hurricanes.csv`).
----------------------------------
## Segment 2: Learning the API
You will be finishing the rest of your lab on `lab-p5.ipynb`. Run the command `jupyter notebook` from your Terminal/PowerShell window.
Remember not to close this
Terminal/PowerShell window while Jupyter is running, and open a new Terminal/PowerShell
window if necessary.
**Note**: For P5, you will be working on `p5.ipynb`, which is very similar to `lab-p5.ipynb`.
It is strongly recommended that you finish this notebook before moving on to P5,
so you can ask your TA/PM any questions about the notebook that may arise.
**Note**: Unlike `p5.ipynb`, you do **not** have to submit `lab-p5.ipynb`. This notebook is solely
for your practice and preparation for P5.
------------------------------
You can now get started with [P5]((https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-f23-projects/-/tree/main/p5)). **You may use any helper functions created here in project P5**. Remember to only work with P5 with your partner from this point on. Have fun!
This diff is collapsed.
# Images
Images from lab-p5 are stored here.
lab-p5/images/table.png

40.1 KiB

This diff is collapsed.
__hurricane__ = []
def __init__():
import csv
"""This function will read in the csv_file and store it in a list of dictionaries"""
__hurricane__.clear()
with open('hurricanes.csv', mode='r') as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
__hurricane__.append(row)
def count():
"""This function will return the number of records in the dataset"""
return len(__hurricane__)
def get_name(idx):
"""get_name(idx) returns the name of the hurricane in row idx"""
return __hurricane__[int(idx)]['name']
def get_formed(idx):
"""get_formed(idx) returns the date of formation of the hurricane in row idx"""
return __hurricane__[int(idx)]['formed']
def get_dissipated(idx):
"""get_dissipated(idx) returns the date of dissipation of the hurricane in row idx"""
return __hurricane__[int(idx)]['dissipated']
def get_mph(idx):
"""get_mph(idx) returns the mph of the hurricane in row idx"""
return int(__hurricane__[int(idx)]['mph'])
def get_damage(idx):
"""get_damage(idx) returns the damage in dollars of the hurricane in row idx"""
return __hurricane__[int(idx)]['damage']
def get_deaths(idx):
"""get_deaths(idx) returns the deaths of the hurricane in row idx"""
return int(__hurricane__[int(idx)]['deaths'])
__init__()
This diff is collapsed.
# Project 5 (P5): Investigating Hurricane Data
## Corrections and clarifications
* None yet.
**Find any issues?** Report to us:
- Takis Chytas <chytas@wisc.edu>
- Samuel Guo <sguo258@wisc.edu>
## Note on Academic Misconduct:
You are **allowed** to work with a partner on your projects. While it is not required that you work with a partner, it is **recommended** that you find a project partner as soon as possible as the projects will get progressively harder. Be careful **not** to work with more than one partner. If you worked with a partner on Lab-P5, you are **not** allowed to finish your project with a different partner. You may either continue to work with the same partner, or work on P5 alone. Now may be a good time to review our [course policies](https://cs220.cs.wisc.edu/f23/syllabus.html).
## Instructions:
This project will focus on **loops** and **strings**. To start, download `p5.ipynb`, `project.py`, `public_tests.py` and `hurricanes.csv`.
**Note:** Please go through [Lab-P5](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-f23-projects/-/tree/main/lab-p5) before you start the project. The lab contains some very important information that will be necessary for you to finish the project.
You will work on `p5.ipynb` and hand it in. You should follow the provided directions for each question. Questions have **specific** directions on what **to do** and what **not to do**.
After you've downloaded the file to your `p5` directory, open a terminal window and use `cd` to navigate to that directory. To make sure you're in the correct directory in the terminal, type `pwd`. To make sure you've downloaded the notebook file, type `ls` to ensure that `p5.ipynb`, `project.py`, `public_tests.py`, and `hurricanes.csv` are listed. Then run the command `jupyter notebook` to start Jupyter, and get started on the project!
**IMPORTANT**: You should **NOT** terminate/close the session where you run the above command. If you need to use any other Terminal/PowerShell commands, open a new window instead. Keep constantly saving your notebook file, by either clicking the "Save and Checkpoint" button (floppy disk) or using the appropriate keyboard shortcut.
------------------------------
## IMPORTANT Submission instructions:
- Review the [Grading Rubric](https://git.doit.wisc.edu/cdis/cs/courses/cs220/cs220-f23-projects/-/tree/main/p5/rubric.md), to ensure that you don't lose points during code review.
- Login to [Gradescope](https://www.gradescope.com/) and upload the zip file into the P5 assignment.
- If you completed the project with a **partner**, make sure to **add their name** by clicking "Add Group Member"
in Gradescope when uploading the P5 zip file.
<img src="images/add_group_member.png" width="400">
**Warning:** You will have to add your partner on Gradescope even if you have filled out this information in your `p5.ipynb` notebook.
- It is **your responsibility** to make sure that your project clears auto-grader tests on the Gradescope test system. Otter test results should be available within forty minutes after your submission (usually within ten minutes). **Ignore** the `-/100.00` that is displayed to the right. You should be able to see both PASS / FAIL results for the 20 test cases, which is accessible via Gradescope Dashboard (as in the image below):
<img src="images/gradescope.png" width="400">
- You can view your **final score** at the **end of the page**. If you pass all tests, then you will receive **full points** for the project. Otherwise, you can see your final score in the **summary** section of the test results (as in the image below):
<img src="images/summary.png" width="400">
If you want more details on why you lost points on a particular test, you can scroll up to find more details about the test.
This diff is collapsed.
This diff is collapsed.
# Images
Images from p5 are stored here.
p5/images/add_group_member.png

157 KiB

p5/images/gradescope.png

60.5 KiB

p5/images/summary.png

20.1 KiB

p5/images/table.PNG

13.5 KiB

p5/p5.ipynb 0 → 100644
This diff is collapsed.
__hurricane__ = []
def __init__():
import csv
"""This function will read in the csv_file and store it in a list of dictionaries"""
__hurricane__.clear()
with open('hurricanes.csv', mode='r') as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
__hurricane__.append(row)
def count():
"""This function will return the number of records in the dataset"""
return len(__hurricane__)
def get_name(idx):
"""get_name(idx) returns the name of the hurricane in row idx"""
return __hurricane__[int(idx)]['name']
def get_formed(idx):
"""get_formed(idx) returns the date of formation of the hurricane in row idx"""
return __hurricane__[int(idx)]['formed']
def get_dissipated(idx):
"""get_dissipated(idx) returns the date of dissipation of the hurricane in row idx"""
return __hurricane__[int(idx)]['dissipated']
def get_mph(idx):
"""get_mph(idx) returns the mph of the hurricane in row idx"""
return int(__hurricane__[int(idx)]['mph'])
def get_damage(idx):
"""get_damage(idx) returns the damage in dollars of the hurricane in row idx"""
return __hurricane__[int(idx)]['damage']
def get_deaths(idx):
"""get_deaths(idx) returns the deaths of the hurricane in row idx"""
return int(__hurricane__[int(idx)]['deaths'])
__init__()
This diff is collapsed.
# Project 5 (P5) grading rubric
## Code reviews
- The Gradescope autograder will make deductions based on the rubric provided below.
- To ensure that you don't lose any points, you must review the rubric and make sure that you have followed the instructions provided in the project correctly.
## Rubric
### General guidelines:
- Did not save the notebook file prior to running the cell containing "export". We cannot see your output if you do not save before generating the zip file. This deduction will become stricter for future projects. (-3)
- Functions are defined more than once. (-3)
- Import statements are not all placed at the top of the notebook. (-1)
- Used concepts or modules not covered in class yet. (-5)
- Hardcoded answers. (all points allotted for that question)
### Question specific guidelines:
- q1 (2)
- required function is not used (-1)
- q2 (3)
- required function is not used (-1)
- q3 (4)
- index of the last hurricane is hardcoded (-3)
- required function is not used (-1)
- q4 (4)
- incorrect logic is used to answer (-2)
- number of hurricanes in the dataset is hardcoded (-1)
- q5 (4)
- incorrect logic is used to answer (-2)
- number of hurricanes in the dataset is hardcoded (-1)
- `format_damage` (4)
- function output is incorrect when the damage has suffix `K` (-1)
- function output is incorrect when the damage has suffix `M` (-1)
- function output is incorrect when the damage has suffix `B` (-1)
- function output is incorrect when the damage has no suffix (-1)
- q6 (4)
- did not exit loop and instead iterated further after finding the hurricane (-2)
- number of hurricanes in the dataset is hardcoded (-1)
- `format_damage` function is not used to convert the damages into an integer (-1)
- q7 (4)
- incorrect logic is used to answer (-2)
- number of hurricanes in the dataset is hardcoded (-1)
- `format_damage` function is not used to convert the damages into an integer (-1)
- q8 (4)
- incorrect logic is used to answer (-2)
- number of hurricanes in the dataset is hardcoded (-1)
- `format_damage` function is not used to convert the damages into an integer (-1)
- q9 (4)
- incorrect logic is used to answer (-2)
- tie breaking is not implemented correctly (-1)
- number of hurricanes in the dataset is hardcoded (-1)
- q10 (4)
- incorrect logic is used to answer (-2)
- tie breaking is not implemented correctly (-1)
- number of hurricanes in the dataset is hardcoded (-1)
- `get_year` (2)
- function logic is incorrect (-2)
- `get_month` (2)
- function logic is incorrect (-2)
- `get_day` (2)
- function logic is incorrect (-2)
- q11 (5)
- variable to store the index or name of the earliest hurricane is not initialized as `None` (-1)
- `get_year` function is not used to determine the year of formation (-1)
- used indices of the hurricanes to determine the earliest hurricane (-1)
- hurricanes with damages <= 1B are not ignored (-1)
- number of hurricanes in the dataset is hardcoded (-1)
- q12 (5)
- variable to store the index or name of the most recent hurricane is not initialized as `None` (-1)
- `get_year` function is not used to determine the year of formation (-1)
- used indices of the hurricanes to determine the most recent hurricane (-1)
- hurricanes with damages <= 100B are not ignored (-1)
- number of hurricanes in the dataset is hardcoded (-1)
- `deadliest_in_range` (4)
- variable to store the index of the deadliest hurricane is not initialized as `None` (-1)
- function does not consider all hurricanes active between `year1` and `year2` (-1)
- number of hurricanes in the dataset is hardcoded (-1)
- function logic is incorrect (-1)
- q13 (4)
- functions `deadliest_in_range` and `format_damage` are not used to answer (-2)
- incorrect logic is used to answer (-2)
- q14 (4)
- function `deadliest_in_range` is not used to answer (-2)
- incorrect logic is used to answer (-2)
- q15 (4)
- functions `get_year` and `get_month` are not used to answer (-1)
- incorrect logic is used to answer (-1)
- number of hurricanes in the dataset is hardcoded (-1)
- `get_year_total` (4)
- function logic is incorrect (-2)
- function `get_year` is not used to answer (-1)
- number of hurricanes in the dataset is hardcoded (-1)
- q16 (4)
- function `get_year_total` is not used to answer (-3)
- q17 (5)
- function `get_year_total` is not used to answer (-2)
- did not loop through the years in the last decade and hardcoded all ten years (-2)
- incorrect logic is used to answer (-1)
- q18 (5)
- `year_with_most_hurricanes` is not initialized as some year in the twentieth century, or as `None` (-2)
- function `get_year_total` is not used to determine the year with the most hurricanes (-1)
- tie breaking is not implemented correctly (-1)
- incorrect logic is used to answer (-1)
- q19 (4)
- hurricanes that formed at the end of one year and dissipated at the end of the next are not considered (-1)
- incorrect logic is used to answer (-1)
- function `get_month` is not used to answer (-1)
- q20 (5)
- years with no deadliest hurricane are not ignored (-1)
- all hurricanes formed between 2001 and 2023 are not considered (-1)
- incorrect logic is used to answer (-1)
- functions `deadliest_in_range` and `format_damage` are not used to answer (-1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment