Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

= BANC is trying to analyze how well the Cal football team performed in the 2019 season. A football game is divided into four

imageimageimageimageimage

= 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

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

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Algorithms questions

Question

Review major psychological issues of childhood.

Answered: 1 week ago