<jupyter_start><jupyter_text>Exercise 3Add the specified code for each code cell, running the cells _in order_. Define a function **`create_game_dict()`** that takes in 4 arguments: the name of the home team in a sports game, the name of the visiting team, the home team's score, and the visiting team's score. The function should return a dictionary with keys for each of these values, for example:```{'home':'UW', 'opp': 'Rutgers', 'home_score': 48, 'opp_score': 13}```<jupyter_code>def create_game_dict(home, visitor, home_score, visit_score):
    return {
        'home': home,
        'opp': visitor,
        'home_score': home_score,
        'opp_score': visit_score
    }<jupyter_output><empty_output><jupyter_text>Use your function to create dictionaries representing the following games (visiting team name and score listed first):- Rutgers @ UW - 13 to 48- Idaho @ UW - 14 to 59- Portland State @ UW - 3 to 41- UW @ Arizona - 35 to 28<jupyter_code>game_1 = create_game_dict('UW', 'Rutgers', 48, 13)
game_2 = create_game_dict('UW', 'Idaho', 59, 14)
game_3 = create_game_dict('UW', 'Portland State', 41, 3)
game_4 = create_game_dict('Arizona', 'UW', 28, 35)<jupyter_output><empty_output><jupyter_text>Create a variable **`season2016`** that is a _list_ containing the 4 game dictionaries. Output the list after you create it.<jupyter_code>season2016 = [game_1, game_2, game_3, game_4]
season2016<jupyter_output><empty_output><jupyter_text>Print the visiting opponent of the 3rd game played in this 2016 season.<jupyter_code>print(season2016[2]['opp'])<jupyter_output>Portland State<jupyter_text>Print out the list of games, each on their own line, in a format `"HOME vs. OPPONENT"`.<jupyter_code>for game in season2016:
    print(game['home'], "vs.", game['opp'])<jupyter_output>UW vs. Rutgers
UW vs. Idaho
UW vs. Portland State
Arizona vs. UW<jupyter_text>Create a variable **`home_won_count`** that is the number of games won by the home team in this piece of the 2016 season. Print out the variable.<jupyter_code>home_won_count = 0
for game in season2016:
    if game['home_score'] > game['opp_score']:
        home_won_count += 1
print("Home team won", home_won_count, "times")<jupyter_output>Home team won 3 times<jupyter_text>Create a variable **`home_point_spread`** which is the _average_ number of points that the home team won by (for games that they won). Print out the variable.<jupyter_code>points_over = 0
for game in season2016: # loop through the element game in all of list season2016
    if game['home_score'] > game['opp_score']: # when the home score is bigger than the visitor score
        points_over += game['home_score'] - game['opp_score'] # add the sum of the difference between home score and visitor score.
home_point_spread = points_over / home_won_count    # create variable  that is the average of total points won by
print(home_point_spread)<jupyter_output>39.333333333333336<jupyter_text>_Bonus_: read in the **`data/huskies_2016.csv`** file and create a new `season2016` variable from that data (each game is written on a new line&mdash;the first line is the header). Then rerun the above calculations for the entire season.- You'll need to skip the "header" line, and remember to convert scores into integers.Optionally, you can use the [csv](https://docs.python.org/3/library/csv.html) module to easily read each line (row) of the file as a _list_ of values, passing the appropriate ones into your `create_game_dict()` function.<jupyter_code>with open(data/huskies_2016.csv)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10002817695125388, 'fraction_numerical': 0.03409411101718794, 'mean_word_length': 5.327985739750446, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '117864', 'license': 'MIT', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1096, 'n_words': 417, 'path': 'exercise-3/exercise.ipynb', 'repo_name': 'michi-gato/ch9-dictionaries', 'size': '3549'}