Homework Assignment 1 - Git, Pandas, new Python packages, and Python classes#

✅ Put your name here.

#

✅ Put your GitHub username here.

#

An image of a tornado, from Wikipedia

Goals for this homework assignment#

By the end of this assignment, you should be able to:

  • Use Git to create a repository, track changes to the files within the repository, and push those changes to a remote repository.

  • Debug some basic Python code that involves Pandas.

  • Read documentation and example code to use a new Python package

  • Modify and use a simple Python class

Work through the following assignment, making sure to follow all of the directions and answer all of the questions.

There are 75 points possible on this assignment. Point values for each part are included in the section headers and question prompts.

This assignment is due at 11:59 pm on Friday, October 2. You will submit it through Gradescope this semester (not D2L): you will upload your completed notebook, an autograder converts it to a PDF, and you then map the PDF pages to the questions for grading. Follow the step-by-step Gradescope Submission Instructions on the course website (also linked at the end of this notebook).

How this connects to the course learning goals#

Beyond the specific goals above, this homework builds toward these course-level learning goals (see the syllabus, or the Day 1 notebook, for the full CLG 1-7 list):

  • CLG 1 - Design and write programs to solve problems: you’ll write pandas analysis code, mapping code with Folium, and a custom VendingMachine class.

  • CLG 4 - Use modern development tools to build reusable programs: you’ll use Git (add/commit/push) throughout and write reusable class code.

  • CLG 2 - Identify and use pre-existing tools and libraries: you’ll read the documentation for a new package (Folium), use pandas and matplotlib, and transparently document your use of AI tools (Part 5).

  • CLG 5 - Manipulate, analyze, and visualize datasets: you’ll load, clean, aggregate, and visualize a real tornado dataset.

  • CLG 7 - Explain your results in writing: you’ll describe data issues, justify your choices, and reflect on your process (including the Part 5 AI audit).

Part 0: Office Hours and Academic Integrity#

CMSE 202 Office Hours/Help Rooms#

This is a reminder that CMSE 202 offers a help room that is available to students across all 3 sections. The help room is a great place to get assistance if you run into challenges while working through your homework assignment.

NOTE: The days before a homework is due the help room tends to be very busy. To ensure you get adequate assistance, it is highly recommended that you start this homework early and seek help from office hours early.

You can find the office hours calendar on the course website.

Office hour and help room locations are directly accessible from the calendar events. Some sessions are virtual, some are in-person, and some are hybrid. Check the event details before attending!

Academic Integrity Statement#

In the markdown cell below, paste your personal academic integrity statement (this can be a statement you have used in the past or a statement you craft now to highlight that your work reflects your own learning, understanding, and honest effort). By including this statement, you are confirming that you are submitting this as your own work and not that of someone else.

Reminder that, if you feel that a generative AI tool might help to support your learning on this assignment, you are encouraged to use the HiTA learning assistant. If you use any generative AI for this assignment, including HiTA, you must cite the usage each time you use information from another source to give appropriate attribution to the origin of your work; See the Course AI Policy for additional details.

Notes: As discussed at the beginning of the course, you are allowed but NOT required to use AI tools (e.g., ChatGPT, Copilot). If you do choose to use them, you must do so in responsible, transparent, and ethical ways. For this particular assignment, if you end up using AI tools, you will be expected to document your usage in an “AI Audit Log” section near the end of this notebook. See the details in the “AI Audit Log” section below.

✎ Put your personal academic integrity statement here. This statement should convey your commitment to doing original work that reflects your own learning, understanding, and honest effort. If you intend to use any generative AI tools, this statement should convey your commitment to using them ethically and responsibly.


Part 1: CLI and Git (10 points)#

Setting up a new folder in your Git repository and adding your HW1#

git is a very important professional tool and we want you to get plenty of practice using it. The following set of questions checks your understanding of using Git and the command line by having you add, commit, and push your homework file in your cmse202-f26-turnin repository. You will share this repo with your course section instructor and TA so that they can pull your completed assignments for grading. Additionally, please verify that your repository is setup as a private repository rather than a public repository.

Note: Uploading your notebook to GitHub here is for practicing Git – it is not how the assignment is turned in for grading. You will still submit the assignment through Gradescope (see the Gradescope Submission Instructions).

✅ Question 1.1 (1 points):

  1. Navigate to your turnin repository on Github and add your section instructor and TA as a collaborator for the repository.

This step is very important since we will need access to your repository to check the status of commits for homework assignments throughout the semester. To show you’ve done this, write the Github usernames of yourself and the instructor and TA below.

You should check the Teams channel, email, or D2L for your section of the course to get this information.

### Write your Github username: ###

### Write your TA Github username: ###

### Write your instructor Github username: ###

✅ Question 1.2 (1 point): Using the command line interface, on your local computer (JupyterHub or your machine) move inside the repository folder

What command did you use to enter into the folder?

# Put the command to move into a new directory here.

✅ Question 1.3 (1 point): Once inside the cmse202-f26-turnin repository, create a new folder called hw-01.

What is the command to create the new folder ?

# Put the command to create the folder/directory here

✅ Question 1.4 (1 point): Move this notebook into that new directory in your repository then check the status of the repository

This is an important step: you’ll want to make sure you save and close the notebook before you do this step and then re-open it once you’ve added it to your local repository directory. If you don’t do this, you could end up working on the wrong version of the notebook! Once you’ve moved the notebook correctly, re-open it and continue working on it.

# Put the command you used to check the status of your repository here.

✅ Question 1.5 (1 point): Once you have checked the status of your repository, copy and paste the output of the status command in the cell below.

# Paste it here

✅ Question 1.6 (1 point): What is the name of the current branch of the repository that you are in? (Hint: There should only be one branch at this time. We’ll learn more about branches in git later in the semester.)

# Put your answer here

✅ Question 1.7 (1 points): If you haven’t already, add your name and GitHub username to the top of the notebook, then add and commit ONLY the notebook. Be sure to use a descriptive commit message!

# Put the command(s) to add and commit here 

What is the commit message you used ?

# Copy your commit message here

✅ Question 1.8 (1 point): Before moving on. Check that the notebook you are working on is the correct one. Run the following cell. Are you in the new folder you just created? If not close this notebook and open the one in the hw-01 folder in your turnin repository. You’ll likely need to copy of over the work you did on the above questions if you were working on the wrong notebook. (The cell should be run to get credit for this question!)

!pwd

✅ Question 1.9 (1 points): Assuming that you notebook is in the right place and committed to your repository, push your changes to GitHub.

What command did you use to push your changes to GitHub?

# Put the command you used to push your changes to GitHub here

✅ Question 1.10 (1 points): To make sure that we can find your repository, what command should the instructor use to clone your repository from the command line?

# Put the command to clone your repo here

Before moving on…#

Important: Make sure you’ve added your Professor and your TA as collaborators to your new “turnin” repository with “Read” access so that they can see your assignment. You should check the Teams channel, email, or D2L for your section of the course to get this information.

Double-check the following: Make sure that the version of this notebook that you are working on is the same one that you just added to your repository! If you are working on a different copy of the notebook, none of your changes will be tracked.

If everything went as intended, the file should now show up on your GitHub account in the “cmse202-f26-turnin” repository inside the hw-01 directory that you just created. Periodically, you’ll be asked to commit your changes to the repository. By the end of the assignment you should have multiple commits that correspond to your completion of each section (as specified below). Of course, you can always commit your changes more often than that, if you wish. It can be good to get into a habit of committing your changes any time you make a significant modification, or when you stop working on the project for a bit.


Part 2: Pandas with a new dataset (21 points)#

For this part of the assignment you will work with data regarding tornadoes in the United States. This data has been managed and compiled for the last few decades by the National Oceanic and Atmospheric Administration (NOAA); more info can be found at https://www.spc.noaa.gov/wcm/#data.

The data itself can be downloaded from

https://www.spc.noaa.gov/wcm/data/1950-2025_actual_tornadoes.csv (data)

and

https://www.spc.noaa.gov/wcm/data/SPC_severe_database_description.pdf (description)

You will need to use the description substantially when you complete this assignment. The data itself is a little messy, so this is good practice for what you might encounter when you work with real data! The data description is also fairly hard to read due to the file format they used. Because of this, we are providing an equivalent document in the form of a Word file, SPC_severe_database_description.docx. You can download it from the “HW-01 Data Description (DOCX)” link in the left sidebar of the course website (listed under “Homework 01”).

✅ Question 2.1 (1 points): Using the command line, download both the dataset and PDF description file to your local file system. What is the command you used to accomplish this task?

# Put the command to download the csv file here

✅ Question 2.2 (2 points): Now that you have the data, let’s use Python to do some basic data analysis. Use Pandas to load in the data and display the first 5 rows.

Note: Use the default options for the read command for now. You will likely get a warning when you load in the data – look at the next question!

# Put your code here

✅ Question 2.3 (3 points): You likely received a warning when you loaded in the data in Question 2.2 that looked something like this:

DtypeWarning: Columns (0,29,30) have mixed types. Specify dtype option on import or set low_memory=False.

Look at the data and the documentation and see what would have caused the issue. You may have to consult the internet to see what the error means! If it is helpful, feel free to write some code to explore the data in the code cell below. Then, in the markdown cell below, describe in 2-3 sentences what the issue is and how you found the issue.

# Use this code cell to explore the data if you like

Explain what caused the issue here - THIS IS WHAT WE WILL LOOK AT TO ASSESS YOUR ANSWER

✅ Question 2.4 (2 points): In the markdown cell below, explain in a few sentences how you would resolve the issue so those three columns have a consistent format all the way through the dataframe. We will not be using these three columns for this assignment, so it is not necessary to implement this code, but you should describe the process in your own words for this question.

Explain how you would fix columns 0, 29, and 30 here

✅ Question 2.5 (6 points): Now let’s start visualizing the data we have. For this question, do the following:

  • Count the total number of tornadoes from each US state. Store these values in an appropriate container such as a pandas dataframe. (2 points)

  • Sort the values in decreasing order, from most to least (1 point)

  • Make a barplot showing states in the x-axis and number of total tornadoes in the dataset on the y-axis (1 point)

  • Be sure to label your axes and title your graph! (2 point)

There are many ways to do this. For example, you could use masking and loops. However, you may find it easier and cleaner to use the .groupby() function, which is built-in to pandas dataframes and can be combined with other functions (documentation found here and user guide found here). Just be sure to cite any resources you use to accomplish this problem!

# Put your code here

✅ Question 2.6 (6 points): Let’s see how the annual number of tornadoes has changed over time – both nationally and for Michigan specifically. Do the following:

  • Count the total number of tornadoes from each year across the entire US. Store these values in an appropriate container such as a pandas dataframe. (1 point)

  • Using masking, filter the dataset to Michigan (MI) only and count the total number of tornadoes from each year in MI. (2 points)

  • Make a plot (or plots) showing year on the x-axis and number of tornadoes on the y-axis, presenting both the US and Michigan trends. You may use two lines on the same axes or two subplots. Be sure to label your axes, give your plot(s) a title, and clearly distinguish the US and Michigan data (e.g., a legend, or subplot titles). (3 points)

There are many ways to do this. Tip: the US has far more tornadoes per year than Michigan, so if you put both on the same axes the Michigan line will look nearly flat – two subplots (or a second y-axis) can make the Michigan trend easier to see.

# Put your code here

✅ Question 2.7 (1 point): Pause to add and commit your changes to your Git repository!

Take a moment to save your notebook, commit the changes to your Git repository using the commit message “Committing Part 2”, no need to push the changes to GitHub, but you can if you want.


Part 3: New Packages (16 points)#

For this section, you will use Folium to plot the geographical data in the tornado data set. You have already used Folium in a previous In-Class Assignment, but here you will explore some more capabilities that you may not have seen. This will give you practice using online documentation and other resources to explore code that you are unfamiliar with.

✅ Question 3.1 (6 points): To get a general sense of the data, we’ll start by making a scatterplot of all the tornadoes that have been recorded in the state of Michigan. To accomplish this, do the following:

  • Start with a folium Map centered on Michigan and zoomed so that the state covers most of the area of the map (2 points)

  • Add a folium CircleMarker at the appropriate coordinates where each tornado that started in the state of Michigan (MI) (which columns will you need to use here?) (2 points)

  • Change the radius of the CircleMarkers so that the map is easy to read - an appropriate size might be 2 or 3 pixels (1 point)

  • Change the color to anything other than the default (1 point)

# Put your code here

✅ Question 3.2 (5 points): With this data, we can also plot an approximate path that each tornado took. For this part, do the following:

  • Start with the same folium Map you used in Question 3.1

  • Add a line for each tornado in MI that has the appropriate starting and ending coordinates - which folium command will you need to use here? (2 points)

  • You will find that some of these paths don’t make sense. Find a way to filter or manipulate the data appropriately so that the paths are reasonable. Your decision for how you handle the data will involve some trade-offs; you will justify your approach in the next problem. (2 points)

  • Change the color to anything other than the default (1 point)

If all goes well, you should end up with something that looks like the map shown on the tornado tracker at the Midwestern Regional Climate Center at Purdue.

# Put your code here

✅ Question 3.3 (2 points): In Question 3.2 you had to decide how to handle tornado records with missing or invalid end coordinates. In 2-3 sentences, describe the approach you chose and justify it using what you observed in the data. Also, identify an alternative approach and what trade-offs would be made with that approach.

✎ Put your answer here.

✅ Question 3.4 (2 points): By this point, you will have needed to use the documentation (the SPC_severe_database_description file) for the dataset substantially in order to choose appropriate columns for analysis. You probably have a few complaints and/or ideas for how the documentation could be improved – the instructional team sure did when we made this assignment! List at least two ways the documentation could be improved.

✎ Put your answer here.

✅ Question 3.5 (1 point): Pause to add and commit your changes to your Git repository!

Take a moment to save your notebook, commit the changes to your Git repository using the commit message “Committing Part 3”, no need to push the changes to GitHub, but you can if you want.


Part 4: Python classes (23 points)#

In this part of the assignment, you will practice defining classes with Python. Here, you will create a class that will emulate the behavior of a vending machine. Below is some skeleton code for us to start. This VendingMachine class has an __init__ method and a Restock method defined, and a stub function for the IsAvailable method. You will add functionality to the class in Q4.1.

## DO NOT MODIFY THIS CELL!! ##
class VendingMachine:
    def __init__(self,starting_treats):
        self.inventory = starting_treats
        self.stash = 0

    def Restock(self,new_list):
        for item in new_list:
            self.inventory.append(item)

    def IsAvailable(self, item):
        pass

✅ Question 4.1 (17 points): In order to make the VendingMachine class functional, do the following:

  • (2 points) Modify the IsAvailable method. This should:

    • Take a string as input

    • Check to see if that item is in the inventory.

    • Return a boolean value.

  • (2 points) Give the machine a new attribute called current_transaction.

    • This should be a numerical value and will be used to store how much money a customer has put in, in dollars.

    • This should be set to zero when the Vending Machine is initialized.

  • (3 points) Add a method to the class called InputCash. This should:

    • take a numerical input

    • add the input amount to the current_transaction attribute.

  • (3 points) Add a method called Vend. This should:

    • take a string as input

    • remove the input string from the inventory attribute.

  • (7 points) Add another method called MakeRequest. This should:

    • Take a string as input

    • Check to see if the current_transaction is greater than or equal to the price of the treat. Let’s be nostalgic and call this 1 dollar.

    • Check to see if the request is an item in the inventory. You should use an existing method to accomplish this check!

    • if the current_transaction value is not sufficient or the item is not available, do nothing

    • if the current_transaction value is sufficient to purchase the treat, and the item is available:

      • Remove one instance of that treat from the inventory. You should use an existing method to accomplish this!

      • add 1 dollar to the stash attribute

      • subtract 1 from the current_transaction

Progress checklist for Q4.1 — build and test your class one piece at a time. Double-click this cell and change each [ ] to [x] as you finish each item:

  • Added the current_transaction attribute, initialized to 0 in __init__

  • IsAvailable(item) returns a boolean for whether the item is in inventory

  • InputCash(amount) adds the amount to current_transaction

  • Vend(item) removes the item from inventory

  • MakeRequest(item) checks funds and availability, then vends, adds $1 to stash, and subtracts $1 from current_transaction

  • The test cell below runs without errors

# Put your redefinition of the VendingMachine class here!

If all goes well, the test cell below should run without errors. If there is an error, it means that your code is incorrect. If there is no error, it is a good indicator that your code is written correctly.

# testing - do not change this cell!
vm1 = VendingMachine(['Twix','Snickers'])
vm1.Restock(['Twix','M&Ms','Chips Ahoy'])
assert(len(vm1.inventory)==5)
assert(vm1.IsAvailable('Twix')==True)
assert(vm1.IsAvailable('Chex Mix')==False)
vm1.InputCash(0.50)
vm1.MakeRequest('Twix')
assert(len(vm1.inventory)==5)
vm1.InputCash(1.75)
vm1.MakeRequest('Chex Mix')
assert(len(vm1.inventory)==5)
vm1.MakeRequest('Twix')
assert(len(vm1.inventory)==4)
vm1.MakeRequest('M&Ms')
assert(len(vm1.inventory)==3)
assert(vm1.stash==2)

✅ Question 4.2 (5 point): This problem might seem rather contrived. The last part of this problem asks you to envision a way we might use this class to do something useful. In the Markdown cell below:

  • Write down one question we might be able to answer if we were to incorporate this class into an Agent Based Model. (1 point)

  • Specify another type of class that might be present in this ABM (1 point)

  • What attributes and methods would this other class have? (at least one attribute and one method) (2 pts)

  • Explain an interaction that might occur with these two classes (1 point)

✎ Put your answer here.

✅ Question 4.3 (1 point): Pause to add and commit your changes to your Git repository!

Take a moment to save your notebook, commit the changes to your Git repository using the commit message “Committing Part 4”, no need to push the changes to GitHub, but you can if you want.


Part 5: AI Audit Log (5 points)#

As mentioned above, you are allowed to use AI tools in the course and for this assignment, but you must complete the table below to give an overview of your usage (in additional to comment tags within your code cells that highlight AI-generated content or usage). If you used AI tools but did not document them here, that would be considered an integrity violation and does not align with your professional responsibility to be transparent about your process and the tools you use.

If you did not use any AI tools, simply state “No AI tools used” in the table below and leave the rest of the columns blank.

Remember, there is no inherent penalty for using AI tools, so transparency is valued here. The goal of this table is to encourage you to be mindful and intentional about how you use AI tools, and to reflect on their role in your workflow.

Add to the table below to document the role AI played in your work. The first row is provided as an example. If you really don’t like Markdown tables, feel free to write a paragraph with the same information, just make sure it is easily readable.

Assignment Section

AI Tool Used

Prompt(s) used

AI-generated Output

YOUR Changes/Why

Did you verify the output? How?

Part 2.2, Reading in tornado data csv

ChatGPT

“How to read csv file with pandas”

Gave some example code, with how to specify different options

I kept the example code with the simplest pandas command as-is because it was sufficient for this question. I did change the filename to match my own file

Yes, I looked at the first 5 rows and they matched with the csv file given

…

…

…

…

…

…

Or, if you prefer, write a paragraph here that addresses the same information as the table above.


Congratulations, you’re done!#

Submit this assignment by uploading it to the course GradeScope page, which you can find by using the dropdown menu on the right side of the navigation bar in D2L. Look for “Homework 01 - Student Notebook Submission” assignment and upload your Jupyter Notebook there – once it uploads, double-check that you submitted the version with your completed solutions! You should also get a confirmation that a PDF version of your submission was successfully built. We will grade the PDF version. Additional details for this submission process will be provided in class and share via Teams, email, and/or D2L.

For the full step-by-step process, see the Gradescope Submission Instructions on the course website.

© Copyright 2026, Department of Computational Mathematics, Science and Engineering at Michigan State University