程序代写代做 html graph Contents Introduction

Contents Introduction
March 4, 2020
2
C200 Programming Assignment No50 Homework
Professor M.M. Dalkilic
Computer Science
School of Informatics, Computing, and Engineering
Indiana University, Bloomington, IN, USA
AlltheDeliverablesforHomework ……………………….. 2
Problem 1: Processing Real Data 3
Starting Code Problem 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Deliverables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Assignment No50 Homework: Data Page 1

Introduction
All the Deliverables for Homework
Add a new folder to your C200 folder named Assignment50. In this new folder you will add the following Python and CSV file for Assignment50.
• Problem 1
– expect.py : Code that will be completed
– data.csv : The CSV file downloaded from the link in the document, renamed to be shorter
• Make sure to commit and push your project and modules by 11pm, Wednesday April 1st 2020.
As always, all the work should be your own. You will complete this before 11pm, Wednesday April 1st 2020. You will submit your work by committing your code to your GitHub repository. You will not turn anything in on canvas. If your timestamp is 11:01P or greater, the homework cannot be graded. So do not wait until 10:58P to turn it in.
Problem modified from original created by Professor Geoffrey Brown.
One additional note: Any test values provided are just to get you started on testing. Just
because your output matches what is in the homework, that does not mean your solution is 100% correct. You still need to come up with some test values on your own so that you can be confident your program works. For grading, your code will be tested with additional values beyond what is in the homework.
Assignment No50 Homework: Data Page 2

Problem 1: Processing Real Data
The majority of your homework problems have been guided in the sense that you were given a clear set of steps to follow and a the code was largely laid out for you. In this problem, you will do most of the work yourself.
• You will download, using a browser, a real data set from the web
• You will write a python program that extracts specific information from the data set • You will plot that information using matplotlib
This problem involves using the following skills:
• Reading a CSV file – https://docs.python.org/3/library/csv.html • Processing the data
• Plotting – https://matplotlib.org/users/index.html
When you utilize a site, such as matplotlib documentation or matplotlib Tutorial, you must put that in a comment in your code. If you want to use a library that has not been used in class, you must message us on Piazza asking.
Some restricted packages are: • pandas
The data set you will use is life expectancy data (to be saved as data.csv) from GHDx Health Data.
Assignment No50 Homework: Data Page 3

1 2 3 4 5 6 7 8 9
10 11 12 13
You should write a function that finds the county in the USA with the worst life expectancy in a given year – use the average of men/women as your metric, (men + women)/2. In the event of ties, take the first one that you find. You should write a function that, given two parameters state, county generates a plot with the life expectancy rates for that county for the years 1985-2010. The plot will have 6 sets of information:
• female life expectancy by
– county – state – nation
• male life expectancy by
– county – state – nation
You should not simply read the whole file and then process the data – real data files are typically too big! Instead, you should extract the data you need as you read the files. For instance, since our function is looking for a specific year, once we get all the data for the year, stop looking at the rest of the file. The assumption is true that the data will be sorted and grouped by year.
def worst_county(year, path):
# TODO
return (state,county)
def plotdata(state,county, filename):
# TODO
if __name__ = “__main__”:
filename = “Assignment50/data.csv”
state,county = worst_county(2005, filename)
plotdata(state,county, filename)
Assignment No50 Homework: Data
Page 4

Your plots should be saved directly to png files. This will be done through matplotlib functionality (see savefig function). Your plot should include a legend for each of the six data types, a separate color for gender and a separate symbol for county/state/national. The x-axis should be years, the y-axis should be life expectancy (as a numerical number).
Your plot should include a title of the form:
xxx County, yyy: Life expectancy
Where xxx is the county name provided in the plotdata function call, and yyy is the State provided in the same function call. All plots must be saved in the Assignment50/ folder of your repository. Update your path that you use to save the files in the program to incorporate that directory. It should not be necessary to use Python functionality beyond what we have covered in class except for the features of the matplotlib and csv modules.
Deliverables Problem 1
• A file named expect.py which completes the task above
• Plots autogenerated in this assignment location. You do not have to turn in any plots explicitly, just guarantee that the plot will be generated. Please remove plots if you have more than 5 autosaved
• The CSV file that you downloaded (so that the TA can run your program without change.)
• This assignment will be graded upon successful completion of the programming task; i.e., generating a graph with the correct information reasonably formatted. We will examine the code for partial credit as well as certain functionality mentioned previously in the document
Assignment No50 Homework: Data Page 5