代写CS 17700 — Lab 06 Fall 2024代做留学生Python程序

Fall 2024 CS 17700 — Lab 06

Submission files: lab06.py

Submission deadline: Monday November 11 @ 11:59 PM

Late deadline: Thursday November 14 @ 11:59 PM (–20% penalty)

Attempts: 10

All times are local to the Purdue West Lafayette campus (Eastern Time)

Objectives:

•   Implement functions based on design criteria

•   Read formatted data from a file

•   Analyze and visualize data through plotting

Description: The Union of European Football Associations (UEFA) would like some insight into the performance of the teams that compete in its Champions League competition. Your Python program will analyze score information from a season of games to determine the winners of each game and the season performance of each team.

Task 1: Game time (20% of grade)

•   Add import matplotlib.pyplot as plt to the top of your lab06.py file.

•   Create a function called load_games which accepts a single required positional parameter named filename (str).

o Use the open() function and a for loop to read the contents of the file line-by-line.

o The file is in comma-separated value format (CSV). The meaning and data type of each column of values is the following:

Team 1 name,Team 2 name,Team 1 score,Team 2 score

str                ,str               ,int               ,int

o Your function should build and return a 2D list, where each sub-list contains the data for a particular game.

[[Team 1 name, Team 2 name, Team 1 score, Team 2 score], ...]

o Warning: you are not permitted to import the csv library; this will earn a score of zero.

•   Your workarea in Vocareum contains several CSV files which will be used to test your program. See the end of this handout for more information on the CSV files.

Example execution 1: (not all lines shown)

>>> load_games ("s_sample.csv")

[['Chelsea', 'Inter Milan', 1, 0],

['Arsenal', 'Liverpool', 3, 5],

['Liverpool', 'Arsenal', 1, 0],

['Inter Milan', 'PSG', 3, 5],

['PSG', 'Juventus', 1, 1],

['AC Milan', 'Inter Milan', 3, 5],

['Barcelona', 'PSG', 3, 0],

['AC Milan', 'Liverpool', 4, 0],

['Chelsea', 'Borussia Dortmund', 1, 4],

['Inter Milan', 'Borussia Dortmund', 4, 5],

...]

Task 2: Team report cards (35% of grade)

•   Create a function called grade_teams which accepts a single required positional parameter: games (the 2D list produced by your load_games function from Task 1).

o For each game, the winning team will be the team with the higher score.

o In the event of a tie (a game in which both teams end with the same score), there is no winner.

o Your function should build and return a dictionary where the keys are the names of all  teams, and the values are a list of two integers: the total number of goals scored by that team during the season, and the total number of games won by that team during the season.

{Team name: [Total goals, Total games won], ...}

•    Some example executions are provided below. The auto-grader may perform. additional tests with other data.

Example execution 2:

>>> grade_teams(games) # from s_sample.csv

{'Chelsea': [10, 2],

'Inter Milan': [31, 2],

'Arsenal': [19, 2],

'Liverpool': [17, 3],

'PSG': [12, 3],

'Juventus': [20, 4],

'AC Milan': [31, 6],

'Barcelona': [29, 4],

'Borussia Dortmund': [23, 4],

'Atletico Madrid': [15, 3],

'Real Madrid': [16, 2],

'Manchester City': [16, 4],

'Bayern Munich': [18, 2]}

Task 3: Plotting (45% of grade)

•   Create a function called plot_goals which accepts a single required positional parameter: report_card (the dictionary produced by your grade_teams function from Task 2).

o Your function will make a bar chart that displays the total number of goals scored by each team during the season.

o The x-axis label is "Teams".

o The y-axis label is "Goals".

o For the x-axis values, use the first three letters of each team name converted to uppercase.

o Hint: use the function call plt.xticks(rotation=-45) to rotate the x-axis labels by –45º degrees. Place a plt.tight_layout() function call immediately before saving and showing the plot. This will ensure that all team name abbreviations are legible.

o Note: the auto-grader requires that you save the resulting plot to a PNG file named o_goals.png. Add a call to plt.savefig("o_goals.png") immediately before using the plt.show() function call.

•    Some example executions are provided below. The auto-grader may perform. additional tests with other data.

Example execution 3:

>>> plot_goals (report_card) # from s_sample.csv

o_goals.png

Policies:

Review the syllabus for policies regarding extensions and academic integrity.

•   All submissions must be made through Vocareum. No work will be accepted via any other method.

•   Your code must be placed into a file named lab06.py inside of the work/ folder in Vocareum. No variation is permitted.

•   You may make up to 10 submissions. Each submission will produce feedback from the auto-grader.

•   Your auto-grader score in Vocareum for your last submission is final.

•   You may make a private post on Ed if you believe your assignment was incorrectly scored by the auto- grader. This must be done within 5 days of the score entering the Brightspace gradebook.

Unit testing: Please refer to the Lab 04 handout for more information on how your work will be graded.

DO NOT CALL input() or print()ANYWHERE except inside the main block (if any). Notes on CSV files:

•   You do not need to edit these files unless it is useful while developing your solution. Do not edit the CSV files with Microsoft Excel as this will change their format and potentially break your code.

•   It is not recommended to make any changes to the CSV files within Vocareum — any such changes will be reset upon each submission.

•   Instead, it is recommended that you download all provided CSV files from Vocareum to your computer  so that you may test your solution with Spyder. Make sure the CSV files are saved to the same folder as your .py solution file.





热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图