12.7k views
5 votes
Back in Exercise 3.2 you created a program for JMU Basketball that printed the scoring for a single player, and in Exercise 3.3 a function that returned all the statistics for a single player. JMU Basketball would now like you to create a function that will print the statistics for a large number of players all at once. Name your program even_more_stats.py. Write a function called print_stats( ) that does two things: 1. prints the names and individual statistics for any number of players; and 2. prints the total number of points, rebounds, and assists for the entire group of players. The function will take a single parameter, a list that contains all the statistics for the players. A sample list is as follows: [('Jefferson', 706, 88, 57), ('Hazel1', 615, 62, 62), ('Tucker' , 551, 137, 17) ] (Statistics from 2020-2021 JMU Women's Basketball Team) The list consists of tuples, each of which lists a player's name, their total points, total rebounds, and total assists for the season. Your code should print a line for each player (as demonstrated below), and then print the total points, total rebounds, and total assists, calculated for the entire list. The output should be as follows: >> print_stats([('Bird', 500, 100, 50), ('Jordan', 450, 90, 45)]) Bird scored 500 points, grabbed 100 rebounds, and made 50 assists. Jordan scored 450 points, grabbed 90 rebounds, and made 45 assists. Total Points: 950 Total Rebounds: 190 Total Assists: 95 Test Failedi Submission does not pass doestring checks: /autograder/submission/even_more_stats.pyilt1: D300 Use "*"triple double quotes"an /autograder/submission/even_more_stats.py:11:1: D103 Missing doestring in public function PEP 8 checks (0.0/1.0) Test Failedi submission does not pass peps checks: /autograder/subonission/even_more_stats.py:19:101: E501 line too long (105 > 100 characters) /autograder/submission/even_more_stats.py:29:1: E305 expected 2 blank lines after elass or function definition, found 1 Test one player (0.0/4.0)

1 Answer

5 votes

Final answer:

The even_more_stats.py program prints the statistics for a large number of players all at once. It calculates and prints the individual statistics for each player, and also prints the total points, rebounds, and assists for the entire group of players.

Step-by-step explanation:

even_more_stats.py

The program even_more_stats.py is designed to print the statistics for a large number of players all at once. The function print_stats() takes a single parameter, a list that contains all the statistics for the players. The function prints the names and individual statistics for each player, and then prints the total number of points, rebounds, and assists for the entire group of players.

Sample Output:

  • Bird scored 500 points, grabbed 100 rebounds, and made 50 assists.
  • Jordan scored 450 points, grabbed 90 rebounds, and made 45 assists.

Total Points: 950
Total Rebounds: 190
Total Assists: 95

User Deluan
by
7.8k points