KCPD Crime Data Frequently, a programmer\'s job will be to aggregate large amoun
ID: 3765778 • Letter: K
Question
KCPD Crime Data
Frequently, a programmer's job will be to aggregate large amounts of information in order to analyze information easier. Many times this involves getting data from multiple files. The Kansas City Missouri government provides open access to a lot of their data.
https://data.kcmo.org/ We’re going to look at crime data for Kansas City Police Department.
Files
incidents.csv Each row contains information about a reported crime. It provides a Report Number, Reported Date, Reported Time, Offense Number, and the Zip Code the offense occurred in. The Report Number ( Report_No ) field is unique in this file.
Details.csv Each row contains information about people involved in the offense. Either Victims or Suspects. The fields in this file are Report Number, Involvement, Race, Sex,
Age, and Firearm Used. You will be mostly using 2 fields from this file. You’ll need the Report Number and the Involvement. If the Involvement field is VIC then the record is for victim information. There can be multiple records with the same Report No in this file. 3. offenses.docx This is a csv file of the offense codes that are used in the incidents file. There are 2 columns Offense and Description. The offense is the offense number from incidents.
Requirements
Display a menu to the user with 3 choices Summary by Zip Code, Victim Count by Offense Type, and Quit. If the user does not choose one of the items in the menu then they will be warned and required to reenter a value.
Summary by zip code will display a the summary of incident counts by each zip code. ( How many offenses occurred in each zip code )
If a zip code is blank or 0 then it will be considered part of zip code 99999 which is for unknown or unreported zip codes.
The output summary will be ordered by zip code
Victim Count by offense type will displays the number of victims for each type of offense.
The output will be ordered by Victim Count in descending order (the offense type with the highest number of victims, then the next highest, etc.)
If you try to read through the details file for every offense, then you'll find your program will be quite slow. You may want to read the files into dictionaries or some other data type to speed up operations. ( Remember looking up by the key
in a dictionary is much quicker than finding a record in a list or tuple )
All of the fields have a header as the top line.
You may assume these files are in the program directory and are named properly.
You may not assume that the files will open without errors. If there is an error opening one, you should warn the user and quit the program.
Useful Modules
CSV module is great for reading comma separated value files. These are text files where the column are separated by single commas. You don’t have to use the csv module, but it can make things simpler. https://docs.python.org/2/library/csv.html
Example Output ( Some of the rows have been removed from the summary by zip code to make the document shorter. You should include all the data in your output )
>>> ================================ RESTART ================================ >>>
KCPD Crime Statistics
Summary by Zip Code
Victim count by offense Type
Q. Quit
==> e
You must choose one of the selections 1,2,Q
KCPD Crime Statistics
Summary by Zip Code
Victim count by offense Type
Q. Quit
==> 1
Zip Code Crimes
====================
809
3983
1749
1037
4718
2080
2060
2005
2928
15
116
655
1011
59
99999 1537
KCPD Crime Statistics
Summary by Zip Code
Victim count by offense Type
Q. Quit
==> 2
Offense Victims
===================================
Stealing 18381
Non Agg Assault 8968
Burglary 8102
Property Damage 4364
Misc Violation 4352
Assault 4227
Auto Theft 3861
Possession/Sale/Dist 2893
Robbery 2672
Fraud 1844
Forgery 712
Family Offense 661
Rape 597
Weapons Law Violation 595
Disorderly Conduct 570
Casualty/Suicide 463
DUI 393
Sex Offense Other 387
Arson 317
Homicide 189
Embezzlement 184
Prostitution 175
Stolen Property 147
Liquor Law Violation 85
Missing/Runaway 3
Loitering 3
KCPD Crime Statistics
Summary by Zip Code
Victim count by offense Type
Q. Quit
==> q
>>>
Explanation / Answer
input[;]variable
input - data
varible- specific name variable for serch data information
for large number data
read data by the diffrent the name
LET and INPUT
let makes the lengthy resticts the usage
line no data data_item1 ,data item2 data_item3,...
line no read avrible 1 variable 2,variable3,...
READ a$ b$ c$ d$ e$
DATA Report Number, Reported Date, Reported Time, Offense Number, and the Zip Code
printd data
READ Summary by Zip Code, Victim Count by Offense Type, and Quit
DATA Summary by Zip Code, Victim Count by Offense Type, and Quit
print data
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.