Skip to main content
留学咨询

辅导案例-ACO 240

By May 15, 2020No Comments

ACO 240 Spring 2020 1 Python Programming Assignment Python Programming Assignment Due: Start of Class Friday, 6 March 2020 In this comprehensive programming assignment, you will combine the various components of the Python programming language that you learned this semester. The program processes observations of storms provided in csv format, which is described at the end of this document. The program will process the CSV data by creating a storm object based on its unique id, origin, storm number, year, and name, including a list of observation objects for that storm. An observation has the properties: date, time, status, latitude, longitude, maximum wind speed, and minimum pressure along with a reference to the storm for which it is an observation. See the UML class specification shown on the next page. The program MUST incorporate the following components: Process the CSV file (hint: use csv.DictReader()) by creating stations and observations as specified above, maintaining the following dictionary: o origin_year_dict: associating a tuple containing an (Origin, Year) to a list of storm objects from that origin and year Using the origin_year_dict: OUTPUT 1> In reverse order, display the year and origin code, the count of storms from that year and origin, and an alphabetical list of the storm names from that origin and year. OUTPUT 1 YYYY OO # List of storm names in alpha order Using the origin_year_dict: OUTPUT 2> In reverse chronological order (most recent year first), display the year followed by the count of storms from that year and then display the storms for that year, which should include the storm name, maximum wind speed, and minimum pressure. The storms displayed for each year should be in descending order based on the maximum wind speed (highest speed first). OUTPUT 2 YYYY #storms Storm_i max_wind_i min_pressure_i Create a dictionary, status_dict, associating a tuple containing the 2 char Status abbreviation with a list of tuples containing a storm object and list of observation objects for storms with observations of that status. See last page of assignment for status abbreviations. Using the status_dict: OUTPUT 3> For each status, ordered from most severe to least severe, display the status and count of storms with that status. For that status, in alphabetical order by storm name, display the storm name, number of observations of that status for that storm, and 2 (date, time) tuples: the most recent observation and the least recent observation. OUTPUT 3 ST #storms Storm_i #status_observations (date1, time1) (date2, time2) Incremental Development Suggestions: Work on the implementation of each checkbox, saving a working version for each incorporated checkbox so that you can earn partial credit if you do not get ALL checkboxes implemented. ACO 240 Spring 2020 2 Python Programming Assignment The code will be structured in one file, named main.py, as shown: On the due date, you will turn in the following: 1. A printout of a document that indicates the status of the implementation that you submitted for assessment along with a statement signed verifying that you followed the academic integrity policy. 2. A printout of your main.py file downloaded from Repl.it. (See download icon in Repl.it) 3. A printout of the execution of your program in Repl.it. (Copy and paste results into text editor.) 4. A zip file that contains all of the above documents submitted in Canvas. REMINDER: THIS IS AN INDIVIDUAL ASSIGNMENT! Only programs that successfully execute will be considered for assessment. *Note: implement __repr__ to return a string representation of a tuple representing the values of the private instance variables. • In the Storm class: include the number of observations – NOT the list of observations (id, origin, storm_num, year, name, number_of_observations) • In the Observation class: include the storm’s name – NOT the storm object (storm_name, date, time, latitude, longitude, max_wind, min_pressure) Storm _id: str _origin: str _storm_num: int _year: int _name: str _observations: list # Observation __init__(self, i, o, s, y, n) add_observation(self, obs) __repr__(self) 6 getter methods: 1 for each private instance variable Observation _storm: Storm _date: int _time: int _status: str _latitude: str _longitude: str _max_wind: int _min_pressure: int __init__(self, s, d, t, st, lat, lon, mw, mp) __repr__(self) 8 getter methods: 1 for each private instance variable # Your name and class # Storm class definition # Observation class definition # Tester code ACO 240 Spring 2020 3 Python Programming Assignment Field Descriptions Key Type Comment Example Value ID String Unique code identifying the storm. First two characters represent the origin of the storm, second two characters represent the storm number for that year, and the last four characters represent the year the storm occurred. “AL092004” Name String Name given to the storm. “IVAN” Date Integer Integer representation of the date(s) of the storm. For a given storm, the dates can change, due to the storm lasting several days. In the format YYYYMMDD. 20040902 Time Integer Integer representation of the UTC time of an observation for a storm. Most times fall into the synoptic times of 0, 600, 1200, or 1800. If an event occurs, the time for that observation can fall in the range of 0 – 2359. First two numbers are the hour and the second two numbers are the minutes. 1800 Event String Identifies observations of storms that correspond to a landfall or some other type of event that requires an observation time outside the synoptic times mentioned above. “L” Status String Two letter abbreviation of the status of the storm. Details below. “HU” Latitude String The latitude of the storm and hemisphere, North or South. “17.3N” Longitude String The longitude of the storm and hemisphere, West or East. “76.5W” Maximum Wind Integer Maximum sustained wind (in knots). 135 Minimum Pressure Integer Minimum pressure (in millibars). 926 Low Wind NE Integer 34 kt wind radii maximum extent in northeastern quadrant. 150 Low Wind SE Integer 34 kt wind radii maximum extent in southeastern quadrant. 90 Low Wind SW Integer 34 kt wind radii maximum extent in southwestern quadrant. 90 Low Wind NW Integer 34 kt wind radii maximum extent in northwestern quadrant. 150 Moderate Wind NE Integer 50 kt wind radii maximum extent in northeastern quadrant. 75 Moderate Wind SE Integer 50 kt wind radii maximum extent in southeastern quadrant. 50 Moderate Wind SW Integer 50 kt wind radii maximum extent in southwestern quadrant. 50 Moderate Wind NW Integer 50 kt wind radii maximum extent in northwestern quadrant. 75 High Wind NE Integer 64 kt wind radii maximum extent in northeastern quadrant. 50 High Wind SE Integer 64 kt wind radii maximum extent in southeastern quadrant. 40 High Wind SW Integer 64 kt wind radii maximum extent in southwestern quadrant. 30 High Wind NW Integer 64 kt wind radii maximum extent in northwestern quadrant. 40 Note: Fields that are listed in gray are NOT included in the Observation object. Storm Status specified in order of severity from highest to lowest: Status Code Name Description HU Hurricane >= 64 knots TS Tropical Storm >= 34 and < 64 knots SS Subtropical Storm >= 34 knots and < 64 knots TD Tropical Depression < 34 knots SD Subtropical Storm < 34 knots EX Extratropical Storm any intensity LO Low Storm not tropical, subtropical, or extratropical (any intensity) WV Tropical Wave any intensity DB Disturbance any intensity

admin

Author admin

More posts by admin