\documentclass[12pt]{article}

\usepackage[letterpaper, portrait, margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{amssymb, amsmath, amsthm}
\usepackage{color}
\usepackage{ulem}
\usepackage{hyperref}
\usepackage{multicol}
\usepackage{enumitem}

\setlength{\parindent}{0cm}

\begin{document}

\begin{center}
\textbf{Introduction to Computer Science I}\\
\textbf{Project: Fatal Police Shootings}\\
\end{center}

\begin{center}\textbf{Overview}\end{center}

The goals of this project are to:
\begin{itemize}
\item Gain experience using Python to analyze real-world data.
\item Practice using Python dictionaries.
\end{itemize}

In this project, you will use Python dictionaries to analyze real-world data on fatal police shootings. You will use dictionaries to investigate whether black people are disproportionately the subject of fatal police shootings, when compared with their representation in the general United States population. Task 1 does not involve any Python programming. Instead, you'll gain familiarity with the data before you start working with it. For Task 2, you will read and add comments to code that has been provided to you, reading data and organizing it into a dictionary. In Task 3, you will use the dictionary that we have constructed, and write some additional code to answer questions about the data. Finally, in Task 4, you will write a short reflection on your findings. As always, be sure to use meaningful variable names and add helpful comments in your program.

\begin{center}\textbf{Task 1: Understanding the data}\end{center}

For this project, you will use data on fatal police shootings that has been compiled by the Washington Post, and is publicly available on GitHub at \url{https://github.com/washingtonpost/data-police-shootings}. We have posted the data file, \texttt{fatal-police-shootings-data.csv}, on the course webpage, to make it a bit easier for you to access.\\

Before you start working with this data using Python, it's important to understand the data that we're working with. To do this, you will spend some time reading about the data, and looking at the \texttt{.csv} file in a spreadsheet program such as Excel or Google Sheets. We have provided a template file, \texttt{template.txt}, for you to record your investigations. In this file, you will write your answers to the following questions:
\begin{itemize}\setlength{\itemindent}{1.6cm}
\item[\textbf{Question 1.}] Follow the link \url{https://github.com/washingtonpost/data-police-shootings} to read about the data. Write a three sentence summary of what is included in this data, and where it comes from.
\item[\textbf{Question 2.}] Open the file \texttt{fatal-police-shootings-data.csv} in a spreadsheet program, such as Excel or Google Sheets. For each column in the data file, answer the following questions.
\begin{itemize}
\item What is the name of the column header? For example, the first one is ``id''.
\item Write one sentence explanation of what information is in this column.
\item Give a few examples of the values in the column, and what they mean. For example, some examples of values in the first column are 22, 325, and 140.\footnote{Note that this dataset allows only a small number of categories for race, and the dataset fails to recognize that some people are multiracial. This is a weakness of the dataset.}
\end{itemize}
\item[\textbf{Question 3.}] In order to compare the representation of black people among the subjects of fatal police shootings to their representation in the general population, we need to know the percent of the United States population which is black. You can find this by googling racial demographics of the United States. Write the answer in the template file, and include a citation.
\end{itemize}

\begin{center}\textbf{Task 2: Reading the data into a dictionary}\end{center}

The next step for this project is  to read the data from the file \texttt{fatal-police-shootings-data.csv} using Python, and organize the data into a Python dictionary. This step has been done for you, and is posted on the course webpage as the file \texttt{police\_shootings.py}. Download this file, and the \texttt{.csv} file containing the data, and save them in the same folder on your computer.

For this task, you don't need to write any code yet. Instead, you will add comments explaining the code that has been provided for you, and answer questions about the structure of the dictionary stored under the variable name \texttt{database}. In addition to reading the code, it can be helpful to run the module, and then use \texttt{print} statements to investigate the structure of the dictionary.

\textbf{Add comments} to the code in the file \texttt{police\_shootings.py}, and answer the following questions in \texttt{project8\_template.txt}:
\begin{itemize}\setlength{\itemindent}{1.6cm}
\item[\textbf{Question 1.}] What information from the file \texttt{fatal-police-shootings-data.csv} is stored in \texttt{database}? That is, which columns from the \texttt{.csv} file are used? Refer to the columns by name, not by number.
\item[\textbf{Question 2.}] What information from the file \texttt{fatal-police-shootings-data.csv} do we use as the keys in \texttt{database}?
\item[\textbf{Question 3.}] What is the type of the values in \texttt{database}? Hint: you can fine this using the line \texttt{type(database[key])}, where you replace \texttt{key} with an example of a key in \texttt{database}.
\item[\textbf{Question 4.}] Looking at one of the values in \texttt{database}, what information does it store? Give a specific example.
\end{itemize}

\begin{center}\textbf{Task 3: Using the database}\end{center}

In this task, you will use Python and the dictionary \texttt{database} which has been created to ask and answer questions about the data. To do this, you will write additional code in the file \texttt{police\_shootings.py}, continuing where the provided code ended, writing code to complete the following tasks:
\begin{itemize}
\item Print the name of the subject of the fatal police shooting with ID number 1694. If you've followed current events in the past few years, this should be a familiar name.
\item Print the name of all subjects of fatal police shootings in Minnesota in the dataset. This will require iteration using a \texttt{for} loop.
\item Create a new dictionary, called \texttt{race\_counts}, which is initialized as an empty dictionary, and built by iterating through \texttt{database}, and following an accumulator pattern. The purpose of this dictionary will be to count the number of occurrences of each race among subjects of fatal police shootings. The keys in this dictionary should be races, and the corresponding values should be the number of subjects of that race.
\item Print the fraction of fatal police shootings with a black subject. This should be a number between 0 and 1, and can be computed by dividing the number of fatal police shootings with a black subject (you can get this from the dictionary \texttt{race\_counts}), by the total number of fatal police shootings (how can you get this without hard coding?).
\end{itemize}

In the template file \texttt{template.txt}, answer the following question:
\begin{itemize}\setlength{\itemindent}{1.6cm}
\item[\textbf{Question 1.}] How does the proportion of black subjects in fatal police shootings compare to the proportion of black people in the United States population?
\end{itemize}

Next, you'll restrict your focus to the fatal police shootings where the subject of the shooting is unarmed, and find the proportion of these shootings with a black subject. To do this, write code in the file \texttt{police\_shootings.py} to complete the following tasks:
\begin{itemize}
\item Create a new dictionary called \texttt{unarmed\_selection}, which is initialized as an empty dictionary, and built by iterating through \texttt{database}, and following an accumulator pattern. This dictionary should have the same structure as \texttt{database}, except it will only contain entries for fatal police shootings where the subject was unarmed.
\item Create a new dictionary, called \texttt{unarmed\_race\_counts}, which is initialized as an empty dictionary, and built by iterating through \texttt{unarmed\_selection}, and following an accumulator pattern. The purpose of this dictionary will be to count the number of occurrences of each race among subjects of fatal police shootings, including only those where the subject is unarmed. The keys in this dictionary should be races, and the corresponding values should be the number of subjects of that race.
\item Print the fraction of unarmed fatal police shootings with a black subject. This should be a number between 0 and 1, and can be computed by dividing the number of unarmed fatal police shootings with a black subject (you can get this from the dictionary \texttt{unarmed\_race\_counts}), by the total number of unarmed fatal police shootings (how can you get this without hard coding?).
\end{itemize}

In the template file \texttt{template.txt}, answer the following question:
\begin{itemize}\setlength{\itemindent}{1.6cm}
\item[\textbf{Question 2.}] How does the proportion of black subjects in fatal police shootings where the subject is unarmed compare to the proportion of black people in the United States population? How does it compare to the proportion of black subjects in all police shootings?
\end{itemize}

\begin{center}\textbf{Task 4: Reflection}\end{center}

\begin{itemize}\setlength{\itemindent}{1.6cm}
\item[\textbf{Question 1.}] For your final task of this project, write a reflection (at least five sentences) on what you learned from this project, in the file \texttt{template.txt}. This can include your reaction to the results of the project, as well as the process of working with the data. This reflection will be graded for completion, not on the content of what you write.
\end{itemize}



\begin{center}\textbf{Submitting your work}\end{center}

For this project, you will need to submit the following file:
\begin{itemize}
\item \texttt{police\_shootings.py}, which is a Python file containing the program you wrote.
\item \texttt{template.txt}, which is a text file containing your answers to all of the questions for this project.
\end{itemize}


\begin{center}\textbf{Grading}\end{center}

You will earn one point for each of the following accomplishments:
\begin{itemize}
\item You have given a correct answer to Question 1 of Task 1, in the file \texttt{template.txt}, summarizing the data and its source.
\item (2 points) You have given a correct answers to Question 2 of Task 1, in the file\texttt{template.txt}, describing the columns in the dataset.
\item You have given a correct answer to Question 3 of Task 1, in the file \texttt{template.txt}, finding the percent of people in the United States who are black.
\item As part of Task 2, you have added helpful comments to \texttt{police\_shootings.py}, making it easier to understand the code that creates the dictionary database.
\item You have given a correct answer to Question 1 of Task 2, in the file \texttt{template.txt}, correctly identifying the information from the dataset that is stored in our database.
\item You have given a correct answer to Question 2 of Task 2, in the file \texttt{template.txt}, correctly identifying the keys in the dictionary.
\item You have given a correct answer to Question 3 of Task 2, in the file \texttt{template.txt}, correctly identifying the type of the values in the dictionary.
\item You have given a correct answer to Question 4 of Task 2, in the file  \texttt{template.txt}, correctly describing the structure of the values of the dictionary.
\item In \texttt{police\_shootings.py}, you have correctly printed the name of the subject of the fatal police shooting with ID number 1694.
\item In \texttt{police\_shootings.py}, you have correctly printed the names of the subjects of all fatal police shootings in Minnesota from the dataset.
\item In \texttt{police\_shootings.py}, you have correctly constructed the dictionary \texttt{race\_counts}, as described.
\item In \texttt{police\_shootings.py}, you correctly print the proportion of fatal police shootings with a black subject.
\item You have given a correct answer to Question 1 of Task 3, in the file \texttt{template.txt}, explaining how the proportion of fatal police shootings with a black subject compares to the representation of black people in the United States population.
\item In \texttt{police\_shootings.py}, you have correctly constructed the dictionary \texttt{unarmed\_selection}, as described.
\item In \texttt{police\_shootings.py}, you have correctly constructed the dictionary \texttt{unarmed\_race\_counts}, as described.
\item In \texttt{police\_shootings.py}, you correctly print the proportion of unarmed fatal police shootings with a black subject.
\item You have given a correct answer to Question 2 of Task 3, in the file \texttt{template.txt}, explaining how the proportion of unarmed fatal police shootings with a black subject compares to the representation of black people in the United States population, and with the proportion of fatal police shootings with a black subject.
\item (2 points) You have written a reflection on this project in the file \texttt{template.txt}. (Graded for completion)
\end{itemize}

\end{document}
