Question: The data provided is the data being referenced in the problem. Problem 4 part 1: Total Sales There is a data file called sales_data.txt containing


The data provided is the data being referenced in the problem.
Problem 4 part 1: Total Sales There is a data file called "sales_data.txt" containing the sales data for each quarter in 2019 for each continent. Read the data into your program and 1) Write a function to compute the sum of the sales for each continent and return it in the form of a dictionary, mapping the string continent_name to the dollar value as a string. Return the dictionary. Do not assume that there will only be 5 continents in the test cases. def total_sales_dict(file_name): total_sales_dict("sales_data.txt") #{ 'Asia': '$114409', # 'Africa': '$53595', # 'Americas': '$154787', # 'Australia/Oceania': '$80694', # 'Europe': $140126'} ### ### AUTOGRADER TEST - DO NOT REMOVE ### AUTOGRADER TEST - DO NOT REMOVE Problem 4 part 2: Total Sales Write a function to create a sales_by_quarter dictionary. It will map a string to a list. In the dictionary the keys are Q1, Q2, Q3 and 24. The list contains tuples (continent, sales) Example: print(sales_by_quarter[Q1') should give: [('Asia', '$4578'), ('Africa', '$2345'), ('Americas', '$10890"),('Australia/Oceania', $2009'), ('Europe', '$9997')] def sales_by_quarter(file_name): sales_by_quarter("sales_data.txt") #{'01": [('Asia', '$4578'), # ('Africa', $2345'), # ('Americas', '$10890'), # Australia/Oceania', $2009'), # ('Europe', '$9997')], # 'Q2': [('Asia', '$28569'), # ('Africa', '$10023'), (Americas', $33529'), ('Australia/Oceania', $19453'), ('Europe', '$29962')], # 'Q3': [('Asia', '$77905'), # ('Africa', '$32337'), ('Americas', $100540'), (Australia/Oceania', '$52345'), # ('Europe', $89934')], # '04': [('Asia', '$3357'), # ('Africa', '$8890'), # (Americas', '$9828'), (Australia/Oceania', '$6887'), ('Europe', '$10233') }} # # # # 1 Asia $4578 $28569 $77905 $3357 2 Africa $2345 $10023 $32337 $8890 3 Americas $10890 $33529 $100540 $9828 4 Australia/Oceania $2009 $19453 $52345 $6887 5 Europe $9997 $29962 $89934 $10233 6
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
