Write a function called gameStats that takes two parameters (1) a list of tuples containing game...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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' }) 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' })
Expert Answer:
Answer rating: 100% (QA)
Define a function gameStats that takes a list of game tuples and team name def gameStatsg... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Given the following relation, LOT, normalize the relation, and all subsequent relations through 3NF. Be sure to indicate primary keys and foreign keys. You need to provide reference statements for...
-
Using the functional dependency notation used in Examples 14.4, 14.5, list the functional dependencies that exist in the below table attached figure. All attributes should be included at least once....
-
Suppose the general solution to some ODE is y = c cos(3x) C2x6 + C3 arctan (x9) + ex - We would say the solution set is an n-parameter family, for which n?
-
You are performing the audit for Premium Pet Care Pty Ltd (PP), which operates a luxury boarding kennel and daycare facility for dogs and cats. PP bill their customers after their pet's stay, with...
-
(a) Write 5 (x + 2x5) dx as a limit of Riemann sums, taking the sample points to be right endpoints. Use a computer algebra system to evaluate the sum and to compute the limit. (b) Use the...
-
A proposed new investment has projected sales of $515,000. Variable costs are 40 percent of sales, and fixed costs are $134,500; depreciation is $52,750. Prepare a pro forma income statement assuming...
-
What does it mean to recommend that an expense or revenue should be "accrued?" Would this be considered "normal?"
-
Jose Fernandez recently became a franchisee in the Cartridge World franchise. Cartridge World specializes in selling replacement cartridges for printers and fax machine cartridges. Jose was pleased...
-
The directors of a company require that all investment projects should be evaluated using either payback period or return on capital employed ( accounting rate of return ) . The target payback period...
-
Case Study Suppose that you are the consultant hired by a manufacturing company to design a suitable inventory management strategy for its Alloy #1 products for determining the weekly production...
-
A. Sold land for $38,100. B. Purchased equipment by issuing a long-term note payable, $26,300. C. Purchased equipment by issuing a short-term note payable, $22,000. D. Paid long-term note payable,...
-
The following transactions relate to the gardening maintenance business of Steve Jones. The balance in the Allowance for Doubtful Debts account on 1 July 2018 was $7440. The bad debts during the year...
-
The following details were obtained from the accounting records of Civil Construction Consultants at the end of the financial year. The firm requires an allowance for doubtful debts of 10% of...
-
While accounting for accounts receivable for Easy DVD Ltd, the following information became available to the accountant. At 1 July 2018, the Allowance for Doubtful Debts account balance was $8100. To...
-
When the German global sportswear brand PUMA redesigned its standalone store in Bengaluru, India, expectations were high. The brand is hugely popular in India and is surging forward with a powerful...
-
Karen Broderick commenced business on 1 July 2018. On 30 June 2019, she found that she had written off debts amounting to $1875. In addition, she found it necessary to create an allowance for...
-
Hi, i need help with the following for a research paper on Job portals Please this should be as detailed as possible with all references included. Based on "two (2) articles at least" with reference...
-
Consider the combustion of methanol below. If 64 grams of methanol reacts with 160 grams of oxygen, what is the CHANGE in volume at STP. 2CH3OH(g) + 3O2(g) 2CO2(g) + 4H2O(1) The volume decreases by...
-
Create three files of any type you choosefor example, word-processing documents, spreadsheets, or pictures. Write an application that determines whether the first two files are located in the same...
-
A compiler can decide to ____________ a final methodthat is, determine the code of the method call when the program is compiled. a. Duplicate b. Override c. Recreate d. Inline
-
In the following array, what is the value of code[2][1]? char[][] code = { {'A ', 'D ', 'M '}, {'P ', 'R ', 'S '}, {'U ', 'V ', 'Z '} }; a. 'P' b. 'R' c. 'U' d. 'V'
-
a. For the allowed energies of a particle in a box to be large, should the box be very big or very small? Explain. b. Which is likely to have larger values for the allowed energies: an atom in a...
-
The molecules in the rods and cones in the eye are tuned to absorb photons of particular energies. The retinal molecule, like many molecules, is a long chain. Electrons can freely move along one...
-
What was the approximate activity of the plutonium source at the start of the mission? A. \(2 \times 10^{21} \mathrm{~Bq}\) B. \(2 \times 10^{19} \mathrm{~Bq}\) C. \(2 \times 10^{17} \mathrm{~Bq}\)...
Study smarter with the SolutionInn App