Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help with this computer science question! I was able to submit a running program but got some errors! Help Please? Question: Errors

I need some help with this computer science question! I was able to submit a running program but got some errors! Help Please?

Question:

image text in transcribedErrors I'm getting:

image text in transcribedMy current code:

def print_stats(stats):

total_points = 0 total_bounds = 0 total_assists = 0

length = len(stats) i = 0

if i

name, p, r, a = stats[i]

print(f"{name} scored {p} points, grabbed {r} rebounds, and make {a} assists.")

total_points += p total_bounds += r total_assists += a

i += 1

print("Total Points:\t", total_points) print("Total Rebounds:\t", total_bounds) print("Total Assists:\t", total_assists)

stats = [('Jefferson', 706, 88, 57), ('Haroll', 615, 62, 62), ('Tucker', 551, 137, 17)]

print_stats(stats)

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 many players (0.0/4.0) Diff is 670 characters long. Set self.naxdiff to None to see it. 1 output incorrect

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions