= BANC is trying to analyze how well the Cal football team performed in the 2019...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
= BANC is trying to analyze how well the Cal football team performed in the 2019 season. A football game is divided into four periods, called quarters. The number of points Cal scored in each quarter, and the number of points their opponent scored in each quarter are stored in a table called cal_fb.csv. #Just run this cell # Read in the cal_fb csv file games= Table().read_table("cal_fb.csv") games.show() Opponent Cal 1Q Cal 2Q Cal 3Q Cal 4Q Opp 1Q Opp 2Q Opp 3Q Opp 4Q UC Davis 0 13 7 7 10 0 3 0 Washington 0 14 0 3 6 North Texas 20 Ole Miss 7 Arizona State 7 Oregon 7 Oregon State 0 Utah Washington State USC Stanford UCLA Illinois 0 6 7 7 7 7 3 7 0 3 0 7 3 3 7 14 3 14 7 0 14 0 7 0 7 3 0 0 3 0 0 0 13 7 14 7 7 7 7 0 7 7 10 7 7 10 10 3 6 O 0 7 21 6 7 3 3 3 0 7 10 0 7 3 17 7 9 O 7 7 10 7 7 0 6 7 3 0 7 Question 1. Write a function called sum_scores. It should take four arguments, where each argument is the team's score for that quarter. It should return the team's total score for that game. : def sum_scores (Q1, Q2, Q3,04): '''Returns the total score calculated by adding up the score of each quar score = Q1+Q2+Q3+Q4 return score sum_scores (14, 7, 3, 0) # DO NOT CHANGE THIS LINE t[5]: 24 grader.check("q1_1") t[6] q1_1 passed! Question 2. Create a new table final_scores with three columns in this specific order: Opponent, Cal Score, Opponent Score. You will have to create the Cal Score and Opponent Score columns. Use the function sum_scores you just defined in the previous question for this problem. Hint: If you want to apply a function that takes in multiple arguments, you can pass multiple column names as arguments in tbl.apply(). The column values will be passed into the corresponding arguments of the function. Take a look at the python reference for syntax. Tip: If you're running into issues creating final_scores, check that cal_scores and opponent_scores output what you want. In [6]: cal_scores = ... opponent_scores = final_scores = ... final_scores In [] grader.check("q1_2") In [10]: In [11]: We can get specific row objects from a table. You can use tbl.row(n) to get the n th row of a table. row.item("column_name") will allow you to select the element that corresponds to column_name in a particular row. Here's an example: In [ ]: # Just run this cell #We got the Axe! games.row(10) #Just run this cell games.row(10).item("Cal 4Q") Question 3. We want to see for a particular game whether or not Cal won. Write a function called did_cal_win. It should take one argument: a row object from the final_scores table. It should return either True if Cal's score was greater than the Opponent's score, and False otherwise. In [12]: def did_cal_win (row): grader.check("q1_3") ]: ]: ]: Question 4. BANC wants to see how Cal did against every opponent during the 2019 season. Using the final_scores table, assign results to an array of True and False values that correspond to whether or not Cal won. Add the results array to the final_scores table, and assign this to final_scores_with_results. Then, respectively assign the number of wins and losses Cal had to cal_wins and cal_losses. Hint: When you only pass a function name and no column labels through tbl.apply(), the function gets applied to every row in tbl results = final_scores_with_results = cal_wins = ... cal_losses = ... # Don't delete or edit the following line: print (f"In the 2019 Season, Cal Football won {cal_wins} games and lost {cal_] grader.check("q1_4") For this one you are on your own! Calculate the average point spead between CAL and their opponents for the 2019 football season. You can use any means necessary to do so, but it must be in Python. #Insert your code here = BANC is trying to analyze how well the Cal football team performed in the 2019 season. A football game is divided into four periods, called quarters. The number of points Cal scored in each quarter, and the number of points their opponent scored in each quarter are stored in a table called cal_fb.csv. #Just run this cell # Read in the cal_fb csv file games= Table().read_table("cal_fb.csv") games.show() Opponent Cal 1Q Cal 2Q Cal 3Q Cal 4Q Opp 1Q Opp 2Q Opp 3Q Opp 4Q UC Davis 0 13 7 7 10 0 3 0 Washington 0 14 0 3 6 North Texas 20 Ole Miss 7 Arizona State 7 Oregon 7 Oregon State 0 Utah Washington State USC Stanford UCLA Illinois 0 6 7 7 7 7 3 7 0 3 0 7 3 3 7 14 3 14 7 0 14 0 7 0 7 3 0 0 3 0 0 0 13 7 14 7 7 7 7 0 7 7 10 7 7 10 10 3 6 O 0 7 21 6 7 3 3 3 0 7 10 0 7 3 17 7 9 O 7 7 10 7 7 0 6 7 3 0 7 Question 1. Write a function called sum_scores. It should take four arguments, where each argument is the team's score for that quarter. It should return the team's total score for that game. : def sum_scores (Q1, Q2, Q3,04): '''Returns the total score calculated by adding up the score of each quar score = Q1+Q2+Q3+Q4 return score sum_scores (14, 7, 3, 0) # DO NOT CHANGE THIS LINE t[5]: 24 grader.check("q1_1") t[6] q1_1 passed! Question 2. Create a new table final_scores with three columns in this specific order: Opponent, Cal Score, Opponent Score. You will have to create the Cal Score and Opponent Score columns. Use the function sum_scores you just defined in the previous question for this problem. Hint: If you want to apply a function that takes in multiple arguments, you can pass multiple column names as arguments in tbl.apply(). The column values will be passed into the corresponding arguments of the function. Take a look at the python reference for syntax. Tip: If you're running into issues creating final_scores, check that cal_scores and opponent_scores output what you want. In [6]: cal_scores = ... opponent_scores = final_scores = ... final_scores In [] grader.check("q1_2") In [10]: In [11]: We can get specific row objects from a table. You can use tbl.row(n) to get the n th row of a table. row.item("column_name") will allow you to select the element that corresponds to column_name in a particular row. Here's an example: In [ ]: # Just run this cell #We got the Axe! games.row(10) #Just run this cell games.row(10).item("Cal 4Q") Question 3. We want to see for a particular game whether or not Cal won. Write a function called did_cal_win. It should take one argument: a row object from the final_scores table. It should return either True if Cal's score was greater than the Opponent's score, and False otherwise. In [12]: def did_cal_win (row): grader.check("q1_3") ]: ]: ]: Question 4. BANC wants to see how Cal did against every opponent during the 2019 season. Using the final_scores table, assign results to an array of True and False values that correspond to whether or not Cal won. Add the results array to the final_scores table, and assign this to final_scores_with_results. Then, respectively assign the number of wins and losses Cal had to cal_wins and cal_losses. Hint: When you only pass a function name and no column labels through tbl.apply(), the function gets applied to every row in tbl results = final_scores_with_results = cal_wins = ... cal_losses = ... # Don't delete or edit the following line: print (f"In the 2019 Season, Cal Football won {cal_wins} games and lost {cal_] grader.check("q1_4") For this one you are on your own! Calculate the average point spead between CAL and their opponents for the 2019 football season. You can use any means necessary to do so, but it must be in Python. #Insert your code here
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
It is late March 2020 and you are a first-year accounting analyst in the financial reporting area at All World Airways (AWA). You have just finished your first yearend close and reporting process....
-
For its first 2 decades of existence, the NBA's Orlando Magic basketball team set seat prices for its 41-game home schedule the same for each game. If a lower-deck seat sold for $150, that was the...
-
What is the future value at the end of the 20th semester of an annuity due with 20 semiannual payments of $500 each, evaluated at an annual interest rate of 10%?
-
For Qiu Company, a mixed cost is $15,000 plus $18 per direct labour hour. Diagram the behaviour of the cost using increments of 500 hours up to 2,500 hours on the horizontal axis and increments of...
-
A square loop, side a, resistance R, lies a distance s from an infinite straight wire that carries current I (Fig. 7.28). Now someone cuts the wire, so that I drops to zero. In what direction does...
-
Identify some of the most common reasons why unmarried couples choose to live together.
-
Denzel needs a new car. At the dealership, he finds the car that he likes. The dealership gives him two payment options: 1. Pay $35,000 for the car today. 2. Pay $4,000 at the end of each quarter for...
-
Required: 2. After all of the transactions for the year ended December 31, 2015, had been posted [including the transactions recorded in part (1) and all adjusting entries], the data that follows...
-
1. Which aspect of the French revolution most disturbed commentators? 2. How would you align each of these writers on a spectrum running from extreme right to extreme left in politics? 3. How would...
-
Analyse Shleifer's noise trader model and examine which type of investors you want to be in Bursa Malaysia by giving your justifications. You are also required to discuss investor sentiment in Bursa...
-
Create problem statement for a research on the resistance to change for the return of tertiary students from online to face to face studies. Please do intext citations and add source of reference.
-
How does Functionalism navigate the complexities of societal change and adaptation, particularly in terms of how institutions evolve to fulfill new functions and accommodate shifting social dynamics?
-
what ways do ecofeminist perspectives analyze the interconnectedness between gender oppression and environmental degradation, highlighting how patriarchal systems exploit both women and nature ?
-
Describe a new insight or perspective gained after reviewing this week's review of the IHI ACA video as it relates to quality and finance. How do you foresee this perspective impacting your practice.
-
Question: How does the saving rate of middle-career individuals compare with that of retirees? Please explain the economic reasoning.
-
Figure Ql(a) demonstrates two cables, B and C are connected to a screw eye at A. Demonstrate Fy and Fe in Cartesian Vector form (i) Determine the magnitude and coordinate direction angles of the...
-
Archangel Corporation prepared the following variance report. Instructions Fill in the appropriate amounts or letters for the question marks in the report. ARCHANGEL CORPORATION Variance...
-
The portion of a program within which you can reference a variable is the variables_____________. a. Scope b. Space c. Domain d. Range
-
The toString() method converts a(n) ____________ to a String. a. char b. int c. float d. All of the above
-
Write an application that asks a user to enter three integers. Display them in ascending and descending order. Save the file as AscendingAndDescending.java.
-
Repeat problem 15 by assuming Data From Problem 15: The boundaryvalue problem for a cantilevered beam can be written as w(x)=c(x)=cx+2x+03x4 i=1
-
A space frame structure as shown in figure 1.29 consists of 25 truss members. Initially, all members have the same circular crosssections with diameter \(d=2.0 \mathrm{in}\). At nodes 1 and 2, a...
-
Solve the differential equation in problem 2 using (a) two and (b) three finite elements. Use the finite element approximation. Plot the exact solution and two and threeelement solutions on the same...
Study smarter with the SolutionInn App