A retail sales company has 3 branches (1, 2 and 3). The companys manager would like to
Question:
A retail sales company has 3 branches (1, 2 and 3). The company’s manager would like to see a report about their monthly profit in each branch. You are required to write Python functions to accomplish this task. Each branch keeps daily records in a sales_BranchID.csv file at the head branch. These files contain lines that represent each day’s total sale amount, and total cost amount as shown in the example below. Each of the 3 files can contain a maximum of 30 lines.
A) Write a function that accepts a Branch_ID (1,2, or 3), then reads all the lines inside the corresponding sales_BranchID.csv (e.g. sales_1.csv) into two dictionaries: sales_dict={day:sales} and cost_dict={day:cost}. Return both dictionaries. Use exception handling for any file errors.
B) Write a function that accepts both dictionaries (sales_dict and cost_dict) of one branch as well as a start day number and end day number representing a range of days (e.g. 1-15). Calculate the total profit of that branch over this date range where total_profit = (sales-cost) . Raise a ValueError exception if the total profit is negative. Return the total profit.
C) Write a function that accepts the 3 sales dictionaries and a day number and prints to the screen the branch ID with the minimum sales amount on that day.
D) Write a main function to test all of your functions.