CSE 231 Computer Project #05 (Python代写,北美程序代写,美国程序代写,Michigan State University代写)

This assignment focuses on the implementation of Python programs to gain more practice with functions, files, exception handling, and most importantly, dictionaries.

联系我们
微信: biyeprodaixie 欢迎联系咨询

本次CS代写的主要涉及如下领域: Python代写,北美程序代写,美国程序代写,Michigan State University代写

CSE 231 Summer 20 20

Computer Project

Assignment Overview

This assignment focuses on the implementation of Python programs to gain more practice with functions, files, exception handling, and most importantly, dictionaries.

It is worth 90 points (9% of course grade) and must be completed no later than 11:59 PM on Tuesday, June 16.

Assignment Deliverable

The deliverable for this assignment is the following file:

proj05.py – the source code for your Python program

Be sure to use the specified file name and to submit it for grading via the Mimir system before the project deadline.

Assignment Background

This exercise is (again) about data manipulation. In this project we will process agricultural data, namely the adoption of different Genetically Modified (GM) crops in the U.S. (http://www.ers.usda.gov). The data was collected over the years 2000- 2016.

The issue of GM food adoption has been a topic of controversy in recent years. In this project we are interested in how the adoption of different GM food and non-food crops has been proceeding in different states. We are going to determine the minimum and maximum adoption by state and the years when the minimum and maximum occurred.

Assignment Specifications

The data files The data files that you use are yearly state-wise percentage plantings for each type of crop:

  • alltablesGEcrops.csv: the actual data from the USDA.
  • data1.csv: data modified to test this project.
  • data2.csv: data modified to test this project, but you do not get to see it

Input: This is real data so it is messy and you have to deal with that. Here are the constraints.

  • All files have the same header, the same number of columns, and are comma separated (i.e. csv format).

  • You do not know ahead of time which crops are in the file (“Crop” column at index 1). Your program needs to determine this. For example, the data2.csv file has different crops!

  • Missouri for some unknown reason has extraneous characters in the state name on some rows. You need to handle those.

  • The last column, the ‘Value’ column at index 6 with the percentage data, sometimes has digits, sometimes is blank, and sometimes has extraneous characters. You need to account for that. We are only interested in rows that have digits in this last column.

  • We are only interested in data for the 50 states, ‘State’ column at index 0. All other rows are to be ignored. We provide a list of state names in the file state_list.txt that you can copy into your program. Note that most states have no entry!

  • We are only interested in “All GE varieties” indicated in the ‘Variety’ column at index 3. All rows with other values in that column are to be ignored.

Output: Here are the specifications for the output

  • Output is by crop, ordered alphabetically by crop name as it appears in the ‘Crop’ column at index 1.
  • For each crop the data is output alphabetically by state name. Each line has these values: state, max year, max value, min year, min value I used this format string: “{:<20s}{:<8s}{:<6d}{:<8s}{:<6d}”
  • When determining minimum and maximum values often there are multiple years with the same value. You are to output the lowest value year if multiple years have the same value.
  1. Specific Requirements

These are additional requirements that you need to satisfy to ensure a full score:

  1. Items 1-9 of the Coding Standard will be enforced for this project
  2. You must use dictionaries in the solution, and they must be used in a meaningful way.

(I read into a dictionary indexed by states where each state had a dictionary by crop with years and percentages. To prepare for output I used a second dictionary index by crop.) 3. There must be at least 4 functions that must perform non-identical operations, and do them in a meaningful way. a. There must be a function named open_file() that takes no arguments and returns a file pointer. If a file is not found, you must display a proper message and reprompt. b. There must be a function named read_file(fp) that takes a file pointer and returns a dictionary. The input file must be closed in this function and never opened again for reading. You get to decide the organization of your dictionary. c. There must be a function named main()called by if name == "main": main() d. There must be at least one other function that does something meaningful (it is good to have more functions).

Suggested Procedure

  • Solve the problem using pencil and paper first. You cannot write a program until you have figured out how to solve the problem. This first step may be done collaboratively with another student. However, once the discussion turns to Python specifics and the subsequent writing of Python statements, you must work on your own.

  • Construct the program one function at a time—testing before moving on.

  • Use the Mirmir system to turn in the first version of your solution. Cycle through the steps to incrementally develop your program:

o Edit your program to add new capabilities.
o Run the program and fix any errors.
o Use the Mirmir system to submit the current version of your solution.
  • Be sure to log out when you leave the room, if you’re working in a public lab.

Test 1

Enter a file: alltablesGEcrops.csv
Crop: Corn
State Max Yr Max Min Yr Min
Illinois 2015 93 2001 16
Indiana 2014 88 2000 11
Iowa 2014 95 2000 30
Kansas 2014 95 2000 33
Michigan 2014 93 2000 12
Minnesota 2011 93 2001 36
Missouri 2014 93 2000 28
Nebraska 2014 96 2000 34
North Dakota 2011 97 2005 75
Ohio 2014 86 2000 9
South Dakota 2016 98 2001 47
Texas 2014 91 2005 72
Wisconsin 2014 92 2000 18
Crop: Soybeans
State Max Yr Max Min Yr Min
Arkansas 2014 99 2000 43
Illinois 2016 94 2000 44
Indiana 2008 96 2000 63
Iowa 2011 97 2000 59
Kansas 2011 96 2000 66
Michigan 2016 95 2000 50
Minnesota 2016 96 2000 46
Mississippi 2014 99 2000 48
Missouri 2010 94 2000 62
Nebraska 2008 97 2000 72
North Dakota 2012 98 2000 22
Ohio 2015 91 2000 48
South Dakota 2009 98 2000 68
Wisconsin 2014 95 2000 51
Crop: Upland cotton
State Max Yr Max Min Yr Min
Alabama 2008 98 2009 91

Enter a file: data1.csv

Crop: Soybeans

Crop: Upland cotton

This is a blind test has different crops and states, but you don’t get to see the input file or the
output.
  • Arkansas
  • California
  • Georgia
  • Louisiana
  • Mississippi
  • Missouri
  • North Carolina
  • Tennessee
  • Texas
  • Test
    • Arkansas State Max Yr Max Min Yr Min
    • Illinois
    • Indiana
    • Iowa
    • Kansas
    • Michigan
    • Minnesota
    • Mississippi
    • Missouri
    • Nebraska
    • North Dakota
    • Ohio
    • South Dakota
    • Wisconsin
    • Alabama State Max Yr Max Min Yr Min
    • Arkansas
    • California
    • Georgia
    • Louisiana
    • Mississippi
    • Missouri
    • North Carolina
    • Tennessee
    • Texas
  • Test

Computer Project #5 Scoring Summary

General Requirements

0 ( 5 pts) Coding standard

Program Implementation Fulfills specifications including the following:

0 ( 5 pts) Function: open_file

0 (15 pts) Function: read_file constructs and returns dictionary

0 (10 pts) Function: main

0 (10 pts) Other function

0 (20 pts) Test 1 (alltablesGEcrops.csv)

0 (15 pts) Test 2 (data1.txt)

0 (10 pts) Test 3 (data2.txt)