Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called gameStats that takes two parameters (1) a list of tuples containing game score and (2) a string corresponding to the

Write a function called gameStats that takes two parameters (1) a list of tuples containing game score and 1. Define a function called gameStats which admits two inputs: a list of tuples and a string Each tuple in Sample Inputs/Outputs: >> scores = [((Florida', 'Stanford'), (13,32)), (('Missouri', 'Massachusetts'),

Write a function called gameStats that takes two parameters (1) a list of tuples containing game score and (2) a string corresponding to the name of a team. The function returns a tuple of two items: total score of the team and a set of all the teams the given team played against. 1. Define a function called gameStats which admits two inputs: a list of tuples and a string Each tuple in the list has the following composite structure: ((Team1, Team2), (score1, score2)). Such a tuple represents a game between Team1 and Team 2 and the number of goals of team1 and team2 are represented by score1 and score2 respectively 3. To get the total score of a given team, you need to traverse the list, find all occurrences of this team and keep accumulating the score. 4. While you're traversing the list, you can also populate a set with the names of all the opponents the team has faced against. 5. Return a tuple with two items (in the given order): total score of the given team, a set of names of all the opponents the given team has played against 2. 1. Define the main function 2. Create a list of tuples in the given format. You can populate this list with values of your choice or you can use the sample inputs given below (Do not use input function to get arguments as it interrupts the autograding scripts) Call the gameStats function with the created list of tuples and a team of your choice (among the names in the list) 3. 4. Print the output from the function call Call the main function using 5. name previous assignments Activate Wind main call as done in the things to 11 Sample Inputs/Outputs: >> scores = [((Florida', 'Stanford'), (13,32)), (('Missouri', 'Massachusetts'), (28, 16) ), (('Massachusetts', 'Stanford'), (48,21) ), (('Stanford', 'Massachusetts'), (12,11))] >> team = "Massachusetts". >> print (gameStats (scores, team) ) >> (75, {'Stanford', 'Missouri'}) [(('Ohio', 'Florida'), (29,45)), (('Florida', 'Stanford'), >> scores = (38,27))] >> team = "Florida" >> print (gameStats (scores, team) ) >> (83, {'Ohio', 'Stanford' })

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Define a function gameStats that takes a list of game tuples and team name def gameStatsg... 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

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions

Question

What was the first language you learned to speak?

Answered: 1 week ago