[SOLVED] 代写 python CSE 231

30 $

File Name: 代写_python_CSE_231.zip
File Size: 197.82 KB

SKU: 9682243374 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


CSE 231
Semester FS19
Programming Project 07
This assignment is worth 50 points (5.0% of the course grade) and must be completed and turned in before 11:59 on Monday, October 28, 2019.
Assignment Overview
• List and Tuples
• File manipulation
Assignment Background
Travelling across the globe is an opportunity to learn about other cultures and to explore unique and exotic locations. Historic landmarks or natural areas are among to top reasons for people to travel. However, travelling can be very expensive, especially international travel. The World Tourism Organization wants to explore how many people make inbound (arrival) and outbound (departure) international travels for each country. They also want to explore the expenses made during inbound travels (receipts) and outbound travels (expenditures).
For this project, you are tasked to build a program that shows the yearly number of arrivals, departures, total receipts, and total expenses from each country between 2009 and 2017. The program needs to read two files: one containing the international travel data between 2009 to 2017 and another with the codes for each country which international travel data is recorded. The data from the first file needs to be stored into a list of yearly data, where each year will have its own list of tuples with the required values for the program to extract and process the information. The program needs to display a table with the information of each country within a single year, as well as the yearly information for a single country. Also, we want to plot the top 20 countries with the highest average expenses and receipts and another plot for the yearly average expenses and receipts for a country.
Project Specifications
1. You must implement the following functions:
a) open_file(prompt_str): This function receives a string which is the message to diplay when prompting the user to enter a filename. The program will try to open a file. An error message should be shown if the file cannot be opened. This function will loop until it receives proper input and successfully opens the file. It returns a file pointer. Note: Use “utf-8 ” encoding when opening the files required for this project. This encoding is used because there are countries with special characters in their name.
fp = open(filename, “r”, encoding = “utf-8”)
b) read_country_code_file(fp): This function receives a file pointer of the file with the country codes and country name separated by “/”. It returns a list of tuples, where each tuple contains the code and name of each country. Use sorted() or

CSE 231 Semester FS19
.sort() to sort the list alphabetically by country code. Note that the file contains a header line.
c) read_travel_file(fp) receives a file pointer of the data file. Use the csv module for reading files because some fields have commas within the field (see note below). For this project, we are only interested in the following columns:
year = int(line[0])
country_name = line[1][:20]
country_code = line[2]
num_departures = int(line[3])
num_arrivals = int(line[4])
expenditures = float(line[5])
receipts = float(line[6])
In addition to these variables, the program must compute the average expenditure per departure and the average receipt per arrival. Some lines might have zero data on the number of arrivals, departures, expenditures, or receipts. When computing the average expenditures and average receipts, the program must check that there are non-zero values for the arrivals and departures. Otherwise the program will give a ZeroDivisionError. If the denominator is zero for an average calculation, set the average to zero.
Divide the number of departures and arrivals by 1,000. Divide the expenditures and receipts by 1,000,000. Multiply the average expenditures and average receipts by 1,000. Then calculate the averages.
Departures are an expense so use departures as the denominator to calculate average expenditures. Similarly, arrivals are revenue so use arrivals as the denominator to calculate average receipts.
Round both averages to two decimal places (use the round() function).
This function returns a list containing multiple lists with tuples for each year between
2009 and 2017. This means that:
data_list = [ List_of_countries_2009, List_of_countries_2010, …]
where each list of countries per year contains tuples with the data for a single country for a single year:
tup = (year, country_name, country_code, num_arrivals, num_departures,
expenditures, receipts, avg_expenditures, avg_receipts)
data_list[ index ].append(tup)
Remember that lists always start at index 0. The file always contains data from 2009 to 2017 with some data from each year. Make sure that the first index of data_list contains the list of tuples for 2009, the second index of data_list contains the list of tuples for 2010, and so on. Hint—the fact that there is data from each year makes your

CSE 231
Semester FS19
task easier: create data_list as a list of empty lists initially, and as you read the file calculate the data_list index based on the year. (If you want a challenge, write the code without the assumption of exactly that many years. Start with an empty data_list list and create a new year list when you encounter a new year in the file. You will have to assume that years are contiguous in the file.)
Once the file is read and all the data is stored in the list of lists, you need to sort the list of each year by the country name. Hint: Iterate through data_list and sort each year list using itemgetter() by country name alphabetically.
d) get_country_code_data(country_code, data_list): This function receives the data_list parameter which is the same list returned by the read_travel_file function and a country code. It returns a list with the tuples from a single country. Iterate through each year in data_list for the tuples whose code is equal to the country_code parameter. Sort the list for the country data per year, in ascending order. If the list of country data per year is empty, return None.
e) display_country_data(country_list): This function receives a list of travel data for a country and displays the travel data for a single country between 2009 and 2017. It also displays the total of each column. The country_list parameter is the samelistreturnedbytheget_country_code_datafunction. Leaveanemptyline before and after the totals. Use the following string formatting for each column:
‘{:<6d}{:>15,.2f}{:>15,.2f}{:>15,.2f}{:>15,.2f}’
f) display_year_data(year_list) This function receives a list of travel data for all countries within a single year and displays the travel data for every country in a single year. It also displays the total of each column. Note that the year_list has only data for one particular year. Use the following string formatting for each column: “{:20s}{:>15,.2f}{:>15,.2f}{:>15,.2f}{:>15,.2f}”.
g) prepare_bar_plot(year_list): This function receives a list of travel data for all countries within a single year. It returns two lists: top 20 countries by average expenditures and top 20 countries by average receipts. The list of average expenditures will contain tuples with the country name and the average expenditure for each country:
(country_name, average_expenditures)
The list of average receipts will contain tuples with the country name and the average receipt for each country:
(country_name, average_receipts)
Build both lists first, sort each list by their average expenditure or average receipt values in descending order. Then, return the top 20 countries of each list with expenditures first and then receipts.
h) prepare_line_plot(country_list): This function receives a list of the travel data for a single country between 2009 and 2017. The country_list parameter is the samelistreturnedbytheget_country_code_datafunction. Thisfunctionreturns

CSE 231 Semester FS19
two lists (in this order): the average expenditures for each year and the average receipts for each year. The country_list data is in order by year, and that order must be maintained. Note that these are not lists of tuples; instead they are simpler lists of values. Also, unlike the previous function you are to return the whole list.
i) main() This function is the starting point of the program. After you display the banner, you need to open two files, one with the travel data and another with the country codes for each country in the travel data, then read the data into lists, and close the files. Then program will repeatedly display the options and prompt the user to select an option from the following menu:
i. Option 1: Display the travel data for each country in a single year. Prompt for a year (validate that input is an integer in the range 2009 – 2017; reprompt if not) and display the selected year data. Prompt whether to use the bar plots for the top 20 countries with the highest average expenditures and top 20 countries with the highest average receipts.
ii. Option 2: Display the yearly travel data for a single country between 2009 and 2017. Prompt for a country code (validation is required! and Capitalization does not matter) and display the selected country data if the data . Prompt whether to plot the line plot for the average expenditures and average receipts per year. Note that all country codes from the country code file are uppercases.
iii. Option 3: Display the country codes. Display the country codes read from the file with the codes. The country code and country name need to be 15 and 25 characters wide
iv. Option 4: Stop the program.
If the user does not enter any of these options, the program needs to display an error
message and prompt again until a valid option is selected. 2. Hints and Notes
a) Need to print a header line? Using multiple string inside a format method, use the “*” operator to unpack the list. Unpacking is used with iterable items (e.g. lists, strings, and tuples) to take each individual value of the iterable and assign it to various argument positions. In other words, each element from the iterable becomes an individual value. For example:
lst = [“I”, “Love”, “Python! “]
print(“{} {} {}”.format(*lst)) # This prints: I love Python!
b) Using the csv module
reader = csv.reader(fp)
next(reader,None) # skip a line, e.g. header
for line_lst in reader: # line_lst is a list

CSE 231
Semester FS19
c)
Provided plotting functions:
a. plot_bar_data(expenditure_list, receipt_lists, year): This function
creates bar plots when the user wants to process the travel data by year. It receives a list of average expenditures per country and a list of average receipts per country. The first bar plots the average expenditures for each country. The second bar plots the average receipts for each country. It returns nothing. When trying to pass Test 4 in Mimir, comment the followingline:
plt.show()
and uncomment the following two lines:
Deliverables
fig.savefig(‘avg_expense_receipts.png’,dpi=100)
fig.clf()
b. plot_line_data(country_code, expenditure_list, receipt_list): This
function creates a plot with two lines when the user wants to process the travel data by country. It receives a list of average expenditures per year and a list of average receipts per year for a single country. It returns nothing. When trying to pass Test 4 in Mimir, comment the following line:
plt.show()
fig.savefig(‘line.png’,dpi=100)
fig.clf()
and uncomment the following two lines:
The deliverable for this assignment is the following file: proj07.py – the source code for your Python program
Be sure to use the specified file name and to submit it for grading via Mimir before the project deadline.
read_travel_file function test:
from proj07 import MIN_YEAR, MAX_YEAR, read_travel_file
file name: ‘travel_data_tiny.csv’
Output:
[[(2009, ‘China’, ‘CHN’, 50875.0, 47656.0, 43702.0, 39675.0, 917.03, 779.85), (2009, ‘Puerto Rico’, ‘PRI’, 3183.0, 1116.0, 1386.0, 3176.0, 1241.94, 997.8), (2009, ‘United States’, ‘USA’, 55103.0, 62130.0, 102953.0, 146002.0, 1657.06, 2649.62)], [(2010, ‘China’, ‘CHN’, 55664.0, 57386.0, 54880.0, 45814.0, 956.33, 823.05), (2010, ‘Paraguay’, ‘PRY’, 465.0, 302.0, 261.0, 243.0, 864.24, 522.58), (2010, ‘Puerto Rico’, ‘PRI’, 3186.0, 980.0, 1180.0, 3211.0, 1204.08, 1007.85), (2010, ‘United States’, ‘USA’, 60010.0, 61061.0, 110049.0, 167996.0, 1802.28, 2799.47)], [(2011, ‘China’, ‘CHN’, 57581.0, 70250.0, 72585.0, 48464.0, 1033.24, 841.67), (2011, ‘Puerto Rico’, ‘PRI’, 3048.0, 924.0, 1196.0, 3143.0, 1294.37, 1031.17), (2011, ‘Russian Federation’, ‘RUS’, 24932.0, 43726.0, 37343.0, 16961.0, 854.02, 680.29), (2011, ‘United States’,

CSE 231 Semester FS19
‘USA’, 62821.0, 59209.0, 116448.0, 187629.0, 1966.73, 2986.72)], [(2012, ‘Belize’, ‘BLZ’, 277.0, 0.0, 39.0, 298.0, 0, 1075.81), (2012, ‘China’, ‘CHN’, 57725.0, 83182.0, 101977.0, 50028.0, 1225.95, 866.66), (2012, ‘Puerto Rico’, ‘PRI’, 3069.0, 876.0, 1156.0, 3193.0, 1319.63, 1040.4), (2012, ‘United States’, ‘USA’, 66657.0, 60697.0, 129902.0, 200997.0, 2140.17, 3015.39)], [(2013, ‘China’, ‘CHN’, 55686.0, 98185.0, 128576.0, 51664.0, 1309.53, 927.77), (2013, ‘Puerto Rico’, ‘PRI’, 3172.0, 839.0, 1139.0, 3311.0, 1357.57, 1043.82), (2013, ‘South Africa’, ‘ZAF’, 9537.0, 0.0, 6491.0, 10468.0, 0, 1097.62), (2013, ‘United States’, ‘USA’, 69995.0, 61344.0, 130148.0, 218496.0, 2121.61, 3121.59)], [(2014, ‘Canada’, ‘CAN’, 16537.0, 33518.0, 41669.0, 20802.0, 1243.18, 1257.91), (2014, ‘China’, ‘CHN’, 55622.0, 116593.0, 227344.0, 44044.0, 1949.89, 791.84), (2014, ‘Puerto Rico’, ‘PRI’, 3246.0, 793.0, 1088.0, 3439.0, 1372.01, 1059.46), (2014, ‘United States’, ‘USA’, 75022.0, 68185.0, 140558.0, 235990.0, 2061.42, 3145.61)], [(2015, ‘China’, ‘CHN’, 56886.0, 127860.0, 249831.0, 44969.0, 1953.94, 790.51), (2015, ‘Puerto Rico’, ‘PRI’, 3542.0, 746.0, 977.0, 3825.0, 1309.65, 1079.9), (2015, ‘United States’, ‘USA’, 77774.0, 74191.0, 150044.0, 249183.0, 2022.4, 3203.94)], [(2016, ‘China’, ‘CHN’, 59270.0, 135130.0, 250112.0, 44432.0, 1850.9, 749.65), (2016, ‘Puerto Rico’, ‘PRI’, 3736.0, 789.0, 1013.0, 3985.0, 1283.9, 1066.65), (2016, ‘United States’, ‘USA’, 76407.0, 80226.0, 160937.0, 246172.0, 2006.05, 3221.85)], [(2017, ‘China’, ‘CHN’, 60740.0, 143035.0, 257733.0, 32617.0, 1801.89, 536.99), (2017, ‘El Salvador’, ‘SLV’, 1556.0, 1871.0, 466.0, 1227.0, 249.06, 788.56), (2017, ‘Puerto Rico’, ‘PRI’, 3797.0, 792.0, 1035.0, 4090.0, 1306.82, 1077.17), (2017, ‘United States’, ‘USA’, 76941.0, 87703.0, 173919.0, 251361.0, 1983.05, 3266.93)]]
read_country_code_file function test:
file name: ‘country_codes_tiny.txt’
Output:
[(‘BLZ’, ‘Belize’), (‘CAN’, ‘Canada’), (‘CHN’, ‘China’), (‘PRI’, ‘Puerto Rico’), (‘PRY’, ‘Paraguay’), (‘RUS’, ‘Russian Federation’), (‘SLV’, ‘El Salvador’), (‘USA’, ‘United States’), (‘ZAF’, ‘South Africa’)]
get_country_code_data function test:
data_list = [[(2009, ‘Puerto Rico’, ‘PRI’, 3183.0, 1116.0, 1386.0, 3176.0, 1241.9354838709678, 997.8008168394597), (2009, ‘United States’, ‘USA’, 55103.0, 62130.0, 102953.0, 146002.0, 1657.0577820698536, 2649.619802914542)], [(2010, ‘Puerto Rico’, ‘PRI’, 3186.0, 980.0, 1180.0, 3211.0, 1204.0816326530612, 1007.8468298807281), (2010, ‘United States’, ‘USA’, 60010.0, 61061.0, 110049.0, 167996.0, 1802.279687525589, 2799.466755540743)], [(2011, ‘Puerto Rico’, ‘PRI’, 3048.0, 924.0, 1196.0, 3143.0, 1294.3722943722944, 1031.1679790026246), (2011, ‘United States’, ‘USA’, 62821.0, 59209.0, 116448.0, 187629.0, 1966.7280312114713, 2986.724184587956)], [(2012, ‘Puerto Rico’, ‘PRI’, 3069.0, 876.0, 1156.0, 3193.0, 1319.6347031963471, 1040.4040404040404), (2012, ‘United States’, ‘USA’, 66657.0, 60697.0, 129902.0, 200997.0, 2140.1716724055555, 3015.3922318736213)], [(2013, ‘Puerto Rico’, ‘PRI’, 3172.0, 839.0, 1139.0, 3311.0, 1357.5685339690106, 1043.8209331651956), (2013, ‘United States’, ‘USA’, 69995.0, 61344.0, 130148.0, 218496.0, 2121.60928534168, 3121.5943995999714)], [(2014, ‘Puerto Rico’, ‘PRI’, 3246.0, 793.0, 1088.0, 3439.0, 1372.0050441361918, 1059.4577942082565), (2014, ‘United States’, ‘USA’, 75022.0, 68185.0, 140558.0, 235990.0, 2061.4211336804283, 3145.610620884541)], [(2015, ‘Puerto Rico’, ‘PRI’, 3542.0, 746.0, 977.0, 3825.0, 1309.6514745308311, 1079.8983625070582), (2015, ‘United States’, ‘USA’, 77774.0, 74191.0, 150044.0, 249183.0, 2022.4016390128181, 3203.937048370921)], [(2016, ‘Puerto Rico’, ‘PRI’, 3736.0, 789.0,

CSE 231 Semester FS19
1013.0, 3985.0, 1283.9036755386567, 1066.6488222698072), (2016, ‘United States’, ‘USA’, 76407.0, 80226.0, 160937.0, 246172.0, 2006.0454216837434, 3221.851401049642)], [(2017, ‘Puerto Rico’, ‘PRI’, 3797.0, 792.0, 1035.0, 4090.0, 1306.818181818182, 1077.166183829339), (2017, ‘United States’, ‘USA’, 76941.0, 87703.0, 173919.0, 251361.0, 1983.0450497702473, 3266.931804889461)]]
country_code = ‘PRI’
Output:
[(2009, ‘Puerto Rico’, ‘PRI’, 3183.0, 1116.0, 1386.0, 3176.0, 1241.9354838709678, 997.8008168394597), (2010, ‘Puerto Rico’, ‘PRI’, 3186.0, 980.0, 1180.0, 3211.0, 1204.0816326530612, 1007.8468298807281), (2011, ‘Puerto Rico’, ‘PRI’, 3048.0, 924.0, 1196.0, 3143.0, 1294.3722943722944, 1031.1679790026246), (2012, ‘Puerto Rico’, ‘PRI’, 3069.0, 876.0, 1156.0, 3193.0, 1319.6347031963471, 1040.4040404040404), (2013, ‘Puerto Rico’, ‘PRI’, 3172.0, 839.0, 1139.0, 3311.0, 1357.5685339690106, 1043.8209331651956), (2014, ‘Puerto Rico’, ‘PRI’, 3246.0, 793.0, 1088.0, 3439.0, 1372.0050441361918, 1059.4577942082565), (2015, ‘Puerto Rico’, ‘PRI’, 3542.0, 746.0, 977.0, 3825.0, 1309.6514745308311, 1079.8983625070582), (2016, ‘Puerto Rico’, ‘PRI’, 3736.0, 789.0, 1013.0, 3985.0, 1283.9036755386567, 1066.6488222698072), (2017, ‘Puerto Rico’, ‘PRI’, 3797.0, 792.0, 1035.0, 4090.0, 1306.818181818182, 1077.166183829339)]
prepare_line_plot function test:
data_list = [(2009, ‘United States’, ‘USA’, 55103.0, 62130.0, 102953.0, 146002.0, 1657.0577820698536, 2649.619802914542), (2010, ‘United States’, ‘USA’, 60010.0, 61061.0, 110049.0, 167996.0, 1802.279687525589, 2799.466755540743), (2011, ‘United States’, ‘USA’, 62821.0, 59209.0, 116448.0, 187629.0, 1966.7280312114713, 2986.724184587956), (2012, ‘United States’, ‘USA’, 66657.0, 60697.0, 129902.0, 200997.0, 2140.1716724055555, 3015.3922318736213), (2013, ‘United States’, ‘USA’, 69995.0, 61344.0, 130148.0, 218496.0, 2121.60928534168, 3121.5943995999714), (2014, ‘United States’, ‘USA’, 75022.0, 68185.0, 140558.0, 235990.0, 2061.4211336804283, 3145.610620884541), (2015, ‘United States’, ‘USA’, 77774.0, 74191.0, 150044.0, 249183.0, 2022.4016390128181, 3203.937048370921), (2016, ‘United States’, ‘USA’, 76407.0, 80226.0, 160937.0, 246172.0, 2006.0454216837434, 3221.851401049642), (2017, ‘United States’, ‘USA’, 76941.0, 87703.0, 173919.0, 251361.0, 1983.0450497702473, 3266.931804889461)];
output:
([1657.0577820698536, 1802.279687525589, 1966.7280312114713, 2140.1716724055555, 2121.60928534168, 2061.4211336804283, 2022.4016390128181, 2006.0454216837434, 1983.0450497702473], [2649.619802914542, 2799.466755540743, 2986.724184587956, 3015.3922318736213, 3121.5943995999714, 3145.610620884541, 3203.937048370921, 3221.851401049642, 3266.931804889461])
prepare_bar_plot function test:
data_list = [(2017, ‘Belgium’, ‘BEL’, 8385.0, 12153.0, 22995.0, 13750.0, 1892.1254011355222, 1639.8330351818724), (2017, ‘Brazil’, ‘BRA’, 6589.0, 9458.0, 22991.0, 6175.0, 2430.852188623388, 937.1680072848687), (2017, ‘China’, ‘CHN’, 60740.0, 143035.0, 257733.0, 32617.0, 1801.8876498759043, 536.9937438261442), (2017, ‘Colombia’, ‘COL’, 4113.0, 4017.0, 5136.0, 5801.0, 1278.5660941000747, 1410.406029662047), (2017, ‘Dominican Republic’, ‘DOM’, 6188.0, 522.0, 941.0, 7178.0,

CSE 231 Semester FS19
1802.6819923371647, 1159.9870717517776), (2017, ‘France’, ‘FRA’, 86861.0, 29055.0, 50329.0, 69894.0, 1732.1975563586302, 804.6649244194748), (2017, ‘Germany’, ‘DEU’, 37452.0, 92402.0, 97597.0, 56173.0, 1056.2217268024501, 1499.8664957812666), (2017, ‘India’, ‘IND’, 15543.0, 23943.0, 21856.0, 27878.0, 912.8346489579418, 1793.6048381908254), (2017, ‘Iran, Islamic Rep.’, ‘IRN’, 4867.0, 10543.0, 0.0, 0.0, 0.0, 0.0), (2017, ‘Israel’, ‘ISR’, 3613.0, 7597.0, 8985.0, 7572.0, 1182.703698828485, 2095.765292001107), (2017, ‘Italy’, ‘ITA’, 58253.0, 31805.0, 27883.0, 44548.0, 876.686055651627, 764.7331467907233), (2017, ‘Japan’, ‘JPN’, 28691.0, 17889.0, 18177.0, 36979.0, 1016.0992788864664, 1288.8710745529957), (2017, ‘Mexico’, ‘MEX’, 39291.0, 19067.0, 13648.0, 22467.0, 715.791681963602, 571.8103382453997), (2017, ‘Netherlands’, ‘NLD’, 17924.0, 0.0, 22044.0, 20352.0, 0, 1135.460834635126), (2017, ‘New Zealand’, ‘NZL’, 3555.0, 2853.0, 4445.0, 10583.0, 1558.0091132141604, 2976.9338959212373), (2017, ‘Nigeria’, ‘NGA’, 0.0, 0.0, 8181.0, 2611.0, 0, 0), (2017, ‘Puerto Rico’, ‘PRI’, 3797.0, 792.0, 1035.0, 4090.0, 1306.818181818182, 1077.166183829339), (2017, ‘Spain’, ‘ESP’, 81786.0, 17031.0, 22321.0, 68437.0, 1310.6100640009395, 836.7813562223363), (2017, ‘Thailand’, ‘THA’, 35592.0, 8963.0, 11579.0, 62158.0, 1291.8665625348656, 1746.4036862216228), (2017, ‘United Kingdom’, ‘GBR’, 37651.0, 74189.0, 71671.0, 51474.0, 966.0596584399304, 1367.1350030543676), (2017, ‘United States’, ‘USA’, 76941.0, 87703.0, 173919.0, 251361.0, 1983.0450497702473, 3266.931804889461)]
Output:
([(‘Brazil’, 2430.852188623388), (‘United States’, 1983.0450497702473), (‘Belgium’, 1892.1254011355222), (‘Dominican Republic’, 1802.6819923371647), (‘China’, 1801.8876498759043), (‘France’, 1732.1975563586302), (‘New Zealand’, 1558.0091132141604), (‘Spain’, 1310.6100640009395), (‘Puerto Rico’, 1306.818181818182), (‘Thailand’, 1291.8665625348656), (‘Colombia’, 1278.5660941000747), (‘Israel’, 1182.703698828485), (‘Germany’, 1056.2217268024501), (‘Japan’, 1016.0992788864664), (‘United Kingdom’, 966.0596584399304), (‘India’, 912.8346489579418), (‘Italy’, 876.686055651627), (‘Mexico’, 715.791681963602), (‘Iran, Islamic Rep.’, 0.0), (‘Netherlands’, 0)], [(‘United States’, 3266.931804889461), (‘New Zealand’, 2976.9338959212373), (‘Israel’, 2095.765292001107), (‘India’, 1793.6048381908254), (‘Thailand’, 1746.4036862216228), (‘Belgium’, 1639.8330351818724), (‘Germany’, 1499.8664957812666), (‘Colombia’, 1410.406029662047), (‘United Kingdom’, 1367.1350030543676), (‘Japan’, 1288.8710745529957), (‘Dominican Republic’, 1159.9870717517776), (‘Netherlands’, 1135.460834635126), (‘Puerto Rico’, 1077.166183829339), (‘Brazil’, 937.1680072848687), (‘Spain’, 836.7813562223363), (‘France’, 804.6649244194748), (‘Italy’, 764.7331467907233), (‘Mexico’, 571.8103382453997), (‘China’, 536.9937438261442), (‘Iran, Islamic Rep.’, 0.0)])

CSE 231 Semester FS19
Test Case 1:
International Travel Data Viewer
This program reads and displays departures, arrivals, expenditures, and receipts for international travels made between 2009 and 2017.
Enter the travel data file: travel_Data_small File not found. Try again.
Enter the travel data file: travel_data_small.csv
Enter the country code file: country_code.txt File not found. Try again.
Enter the country code file: country_codes..txt
File not found. Try again.
Enter the country code file: country_codes.txt
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 1
Enter year: 2016
Country Name Departures (thousands) Barbados 0.00 Cayman Islands 0.00 Dominican Republic 500.00 Greece 7,235.00 Italy 29,067.00 Luxembourg 1,588.00 Namibia 0.00 Poland 44,500.00 Somalia 0.00 Trinidad and Tobago 0.00 Zimbabwe 3,192.00
Total 86,082.00
Do you want to plot (yes/no)? no
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 4
Thanks for using this program!
Arrivals
(thousands)
632.00
385.00
5,959.30
24,799.00
52,372.00
1,054.00
1,469.00
17,471.00
0.00
409.00
2,168.00
106,718.30
Expenditures
(millions)
0.00
166.00
882.00
3,415.00
24,982.00
2,912.00
82.00
8,617.00
0.00
230.00
406.00
41,692.00
Receipts
(millions)
1,040.00
657.00
6,720.00
16,533.00
40,373.00
4,764.00
378.00
12,052.00
0.00
708.00
194.00
83,419.00
Travel Data for 2016

CSE 231 Semester FS19
Test Case 2:
International Travel Data Viewer
This program reads and displays departures, arrivals, expenditures, and receipts for international travels made between 2009 and 2017.
Enter the travel data file: travel_data_2009-2017.csv Enter the country code file: country_codes.txt
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 3
Country Code Reference
Country Code
ABW
AFG
AGO
ALB
AND
ARE
ARG
Country Name
Aruba
Afghanistan
Angola
Albania
Andorra
United Arab Emirates
Argentina
(To many countries to show in this document! See Mimir test for full view)
USAUnited States
UZBUzbekistan
VCTSt. Vincent and the Grenadines
VENVenezuela, RB
VGBBritish Virgin Islands
VIRVirgin Islands (U.S.)
VNMVietnam
VUTVanuatu
WSMSamoa
XKXKosovo
YEMYemen, Rep.
ZAFSouth Africa
ZMBZambia
ZWEZimbabwe
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 2

CSE 231
Semester FS19
Enter country code: PUR
Country code is not found! Try Again! Enter country code: prI
Year
2009
2010
2011
2012
2013
2014
2015
2016
2017
Departures
(thousands)
1,116.00
980.00
924.00
876.00
839.00
793.00
746.00
789.00
792.00
Travel Data for Puerto Rico
Arrivals Expenditures
Receipts
(millions)
3,176.00
3,211.00
3,143.00
3,193.00
3,311.00
3,439.00
3,825.00
3,985.00
4,090.00
31,373.00
Total7,855.00
Do you want to plot (yes/no)? no
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 4
Thanks for using this program!
Test Case 3:
International Travel Data Viewer
(thousands)
3,183.00
3,186.00
3,048.00
3,069.00
3,172.00
3,246.00
3,542.00
3,736.00
3,797.00
(millions)
1,386.00
1,180.00
1,196.00
1,156.00
1,139.00
1,088.00
977.00
1,013.00
1,035.00
10,170.00
29,979.00
This program reads and displays departures, arrivals, expenditures, and receipts for international travels made between 2009 and 2017.
Enter the travel data file: travel_data_2009-2017.csv Enter the country code file: country_codes.txt
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 8
Invalid option. Try Again!
Menu
1: Display data by year
2: Display data by country
3: Display country codes

CSE 231
Semester FS19
4: Stop the Program
Enter option number: 1
Enter year: 2000
Year needs to be between 2009 and 2017. Try Again!
Enter year: 2017
Travel Data for 2017
Country Name Departures
(thousands)
Afghanistan0.00
Albania5,186.00
Algeria5,058.00
American Samoa 0.00
Andorra0.00
Angola 0.00
Antigua and Barbuda0.00
Argentina 12,258.00
Arrivals
(thousands)
0.00
4,643.00
2,451.00
20.00
0.00
261.00
247.00
6,720.00
Expenditures
(millions)
132.00
1,472.00
632.00
0.00
0.00
1,216.00
106.00
13,516.00
Receipts
(millions)
19.00
2,049.00
172.00
22.00
0.00
884.00
774.00
5,514.00
251,361.00
2,666.00
0.00
0.00
0.00
8,890.00
0.00
225.00
0.00
653.00
158.00
1,488,695.20
(To many countries to show in this document! See Mimir test for full view)
United States 87,703.00 Uruguay 1,789.00 Uzbekistan 0.00 Vanuatu 28.00 Venezuela, RB 1,079.00 Vietnam 0.00
76,941.00 173,919.00
3,674.00 1,356.00
2,690.00 0.00
109.00 0.00
427.00 0.00
12,922.00 5,040.00
0.00 0.00
503.00 773.00
0.00 0.00
1,083.00 410.00
2,423.00 338.00
1,289,720.30 1,399,063.00
Virgin Islands (U.S.
West Bank and Gaza
Yemen, Rep.
Zambia 0.00
Zimbabwe 2,768.00
Total1,159,077.00
Do you want to plot (yes/no)? no
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 2
Enter country code: USa
Year Departures
(thousands)
200962,130.00
201061,061.00
201159,209.00
201260,697.00
201361,344.00
201468,185.00
201574,191.00
Travel Data for United States
Arrivals Expenditures
Receipts
(millions)
146,002.00
167,996.00
187,629.00
200,997.00
218,496.00
235,990.00
249,183.00
(thousands)
55,103.00
60,010.00
62,821.00
66,657.00
69,995.00
75,022.00
77,774.00
(millions)
102,953.00
110,049.00
116,448.00
129,902.00
130,148.00
140,558.00
150,044.00
0.00
0.00
0.00

CSE 231
Semester FS19
2016 2017
80,226.00
87,703.00
76,407.00
76,941.00
160,937.00
173,919.00
246,172.00
251,361.00
Total 614,746.00 620,730.00 1,214,958.00 1,903,826.00 Do you want to plot (yes/no)? no
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 4
Thanks for using this program!
Test Case 4:
International Travel Data Viewer
This program reads and displays departures, arrivals, expenditures, and receipts for international travels made between 2009 and 2017.
Enter the filename to read: travel_data_2009-2017.csv Enter the filename to read: country_codes.txt
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 1
Enter year: 2017
Country Name
Afghanistan
Albania
Algeria
American Samoa
Andorra
Angola
Antigua and Barbuda
Argentina
Travel Data for 2017
Departures Arrivals Expenditures Receipts
(thousands)(thousands)(millions) (millions)
0.00 0.00 132.00
4,643.00 5,186.00 1,472.00
2,451.00 5,058.00 632.00
20.000.00 0.00
0.00 0.00 0.00
261.00 0.00 1,216.00
247.00 0.00 106.00
6,720.00 12,258.0013,516.00
19.00
2,049.00
172.00
22.00
0.00
884.00
774.00
5,514.00
(To many countries to show in this document! See Mimir test for full view)
United States 76,941.00 87,703.00 173,919.00 251,361.00

CSE 231
Semester FS19
Uruguay
Uzbekistan
Vanuatu
Venezuela, RB
Vietnam
Virgin Islands (U.S.
West Bank and Gaza
Yemen, Rep.
Zambia
Zimbabwe
Total
Do you want to plot (yes/no)? yeS
3,674.00
2,690.00
109.00
427.00
12,922.00
0.00
503.00
0.00
1,083.00
2,423.00
1,789.00 1,356.00 0.00 0.00 28.00 0.00 1,079.00 0.00 0.00 5,040.00 0.00 0.00 0.00 773.00 0.00 0.00 0.00 410.00 2,768.00 338.00
1,159,077.00 1,399,063.00
2,666.00
0.00
0.00
0.00
8,890.00
0.00
225.00
0.00
653.00
158.00
1,488,695.20
1,289,720.30

CSE 231
Semester FS19
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program

CSE 231 Semester FS19
Enter option number: 2
Enter country code: USa
Travel Data for United States
Year Departures Arrivals Expenditures Receipts
(thousands)(thousands)(millions) (millions)
200955,103.00
201060,010.00
201162,821.00
201266,657.00
201369,995.00
201475,022.00
201577,774.00
201676,407.00
201776,941.00
Total 620,730.00
Do you want to plot (yes/no)? yes
62,130.00
61,061.00
59,209.00
60,697.00
61,344.00
68,185.00
74,191.00
80,226.00
87,703.00
102,953.00
110,049.00
116,448.00
129,902.00
130,148.00
140,558.00
150,044.00
160,937.00
173,919.00
1,214,958.00
146,002.00
167,996.00
187,629.00
200,997.00
218,496.00
235,990.00
249,183.00
246,172.00
251,361.00
1,903,826.00
614,746.00
Menu
1: Display data by year
2: Display data by country
3: Display country codes
4: Stop the Program
Enter option number: 4
Thanks for using this program!

CSE 231
Semester FS19
Grading Rubrics
Computer Project #07
Summary
General Requirements:
(5 pts) Coding Standard 1-9
Scoring
(descriptive comments, function headers, etc…)
Implementation:
(4 pts) open_file (No Mimir Test)
-2 points No try/except
-2 points No while loop
(5 pts) read_travel_file function test
(4 pts) read_country_code_file function test
(4 pts) get_country_code_data function test
(4 pts) prepare_bar_plot function test
(4 pts) prepare_line_plot function test
(5 pts) Pass Test1
(5 pts) Pass Test2
(5 pts) Pass Test3
(5 pts) Pass Test4
(-3 if your plotting is not correct)
Note: hard coding an answer earns zero points for the whole
project
-10 points for not using main()

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] 代写 python CSE 231
30 $