Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me write the Python Code for Question 2? Shoumik is trying to analyze how well the Cal football team performed in the

Can you help me write the Python Code for Question 2?image text in transcribed

image text in transcribedimage text in transcribed

Shoumik 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. In [5]: # Just run this cell # Read in the cal_fb csv file games = Table().read_table("cal_fb.csv") games.show() Opponent Cal 1Q Cal 20 Cal 3Q Cal 4Q Opp 1Q Opp 20 Opp 3Q Opp 40 UC Davis 0 13 7 7 10 0 3 0 Washington D 3 14 3 0 10 3 6 North Texas 200 3 0 0 3 7 7 Ole Miss 7 7 14 0 7 6 0 7 Arizona State 7 0 7 3 7 0 7 10 Oregon 7 0 0 0 0 0 10 Oregon State 3 14 0 7 7 0 Utah 0 0 0 7 217 Washington State 7 7 13 5 6 3 USC 3 0 7 10 7 17 Stanford 14 7 3 7 UCLA 7 7 7 Illinois 7 14 7 7 10 3 0 7 Let's start by finding the total points each team scored in a game. Let's start by finding the total points each team scored in a game. 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. In [6]: def sum_scores(a,b,c,d): ''Returns the total score calculated by adding up the score of each quarter'' sum= a + b + c + d print(sum) sum_scores(14, 7, 3, 0) #DO NOT CHANGE THIS LINE 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 Shoumik 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. In [5]: # Just run this cell # Read in the cal_fb csv file games = Table().read_table("cal_fb.csv") games.show() Opponent Cal 1Q Cal 20 Cal 3Q Cal 4Q Opp 1Q Opp 20 Opp 3Q Opp 40 UC Davis 0 13 7 7 10 0 3 0 Washington D 3 14 3 0 10 3 6 North Texas 200 3 0 0 3 7 7 Ole Miss 7 7 14 0 7 6 0 7 Arizona State 7 0 7 3 7 0 7 10 Oregon 7 0 0 0 0 0 10 Oregon State 3 14 0 7 7 0 Utah 0 0 0 7 217 Washington State 7 7 13 5 6 3 USC 3 0 7 10 7 17 Stanford 14 7 3 7 UCLA 7 7 7 Illinois 7 14 7 7 10 3 0 7 Let's start by finding the total points each team scored in a game. Let's start by finding the total points each team scored in a game. 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. In [6]: def sum_scores(a,b,c,d): ''Returns the total score calculated by adding up the score of each quarter'' sum= a + b + c + d print(sum) sum_scores(14, 7, 3, 0) #DO NOT CHANGE THIS LINE 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

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

Database Theory Icdt 99 7th International Conference Jerusalem Israel January 10 12 1999 Proceedings Lncs 1540

Authors: Catriel Beeri ,Peter Buneman

1st Edition

3540654526, 978-3540654520

More Books

Students also viewed these Databases questions

Question

fscanf retums a special value EOF that stands for...

Answered: 1 week ago

Question

1. Outline the listening process and styles of listening

Answered: 1 week ago

Question

4. Explain key barriers to competent intercultural communication

Answered: 1 week ago