Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 3 (14 points): Purpose: To practice your ability to modify lists and compute values with lists Degree of Difficulty: Moderate For this question, you
Question 3 (14 points): Purpose: To practice your ability to modify lists and compute values with lists Degree of Difficulty: Moderate For this question, you will write a program that uses player statistics to determine how well a lacrosse team performed during the 2019 season. Starter File a4q3_starter.py is a file that contains a list of lists which represents the 2019 statistics for each player on the Saskatchewan Rush. Each sublist has exactly 6 items in the following order: 1. the player's name 2. the player's position ('Forward", "Defence, "Transition' or 'Goalie") 3. the number of games played 4. the number of goals scored 5. the number of assists made 6. the number of penalty minutes served Just copy/paste this list of lists to the top of your program. But keep in mind that your code should work even if we use a different starting list (though with the same format) to test your program. From here, you will write four separate functions to perform the tasks described below. Calculating the Total Number of Goals Scored Write a function called totalGoals() that takes the list of lists described above as a parameter. This func- tion should calculate and return a single integer representing the total number of goals scored by the team. Calculating the Average Number of Penalty Minutes Write a function called avgPenaltyMinutes) that takes the list of lists (described above) and a string as parameters. The second parameter will encode a valid position on the team (ie, one of "Forward" "Defence". "Transition' or "Goalie"). This function should calculate and return the average number of penalty minutes acquired by all of the players with the specified position. Identifying the player that served the Most Penalty Minutes per Game Write a function called mostPenalities that takes the list of lists (described above) as a parameter. This function should return the name of the player with the highest ratio of penalty minutes per games played. https://www.nll.com/stats/all-player-stats/?season=2019regular&fteam=Saskatchewan& 1This data was extracted from experience=&position= Calculating Player Points (Goals + Assists) Write a function called pointsPerPlayer() that takes the list of lists (described above) as a parameter. For each player on the team, this function should append a new value to the sublist that represents the total number of points they acquired (i.e. goals + assists). These changes should be done by modifying the input list itself. No new lists should be created and this function has no return value. After this function is executed, print (roster[1]) should display: ['Scott Campbell', 'Defence', 8, 1, 4, 0, 5] Program Output At the very bottom of your program, call all of the functions you made above and use their return values appropriately to print out the numbers of goals the Saskatchewan Rush scored in 2019, the average num- ber of penalty minutes incurred by defence players on the team and the name of the player who served the most penalty minutes per game played. Finally, display the statistics for each player on the team. Sample Run Here is an example of how your program's console output might look (the output will in fact be much longer; we are showing only the first players here to save space). The SK rush scored 222 goals in 2019. The Defence averaged 14.43 penalty minutes. Nik Bilic served the most penalty minutes per game. Player Statistics ------------- Nik Bilic Defence 16 0 5 61 5 Scott Campbell Defence 8 1 4 0 5 Robert Church Forward 17 25 42 2 67 What to Hand In Hand in your solution in a file called a4q3.py. Evaluation . -1 mark for missing name, NSID and student number at top of file 2 marks for totalGoals() 3 marks for avgPenaltyMinutes() 3 marks for most Penalties() 3 marks for pointsPerPlayer() 1 mark for function calls and printing output . 2 marks for docstrings for each function and appropriate comments roster = Defence, 931, 0, oj, Keenan, [["Nik Bilic", "Defence", 16, 6, 5, 61), ["Scott Campbell", "Defence", 8, 1, 4, 0], ["Robert Church", "Forward", 17, 25, 42, 2], ["Chris Corbeil", "Transition", 17, 4, 10, 8], ["Travis Cornwall", "Transition", 17, 0, 6, 2] ["Matthew Dinsdale", "Forward", 18, 20, 27, 6], ["Nick Finlay", "Defence", 6, 1, 0, 0], [ "Matt Hossack", "Defence", 18, 3, 14, 10), [ "Ryan Keenan", "Forward", 18, 20, 42, 11], ["Evan Kirk", "Goalie", 12, 0, 0, 0, 0], ["Curtis Knight", "Forward", 18, 13, 35, 2], ["Matt MacGrotty", "Defence", 6, 1, 2, 0], [ "Mark Matthews", "Forward", 18, 41, 64, 8], ["Ben McIntosh", "Forward", 18, 41, 36, 4], ["Mike Messenger", "Transition", 18, 9, 6, 17], ["Brett Mydske", "Defence", 17, 2, 3, 12], ["Conor Robinson", "Forward", 3, 1, 3, 0], ["Kyle Rubisch", "Defence", 18, 2, 6, 18], ["Jeff Shattler", "Forward", 18, 34, 39, 14], ["Adam Schute", "Goalie", 9, 0, 2, 0], ["Jermey Thompson", "Transition", 18, 3, 7, 28), ["Jordi Jones-Smith", "Transition", 14, 1, 0, 6]]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started