Question: In this week's exercise, we're going to write an app that reads in receipts from files which are in a specific format. As in last

 In this week's exercise, we're going to write an app that
reads in receipts from files which are in a specific format. As
in last week's assignent, we'tl be assigning amounts categories, but some are
new this week. Here are the categories: TR - Transportation FO -

In this week's exercise, we're going to write an app that reads in receipts from files which are in a specific format. As in last week's assignent, we'tl be assigning amounts categories, but some are new this week. Here are the categories: TR - Transportation FO - Food CL - Clothing PE - Personal ME - Medical For each receipt read in from a file, each line contains the type of expense and the amount in the following format, with two letiter codes to 20 entify the expense type, three spaces, and then the amount. TRFOCLPEME28.008.9045.0012.95260.00 There are ten days worth of receipts in the files: daye1. txt daye2, txt day10, txt \# Q3: Within the file processing loop, after reading in the line, \# separate each line into two parts using list slicing, and assign them * to variables for the type and amount of the receipt \# Then use if statements to identify the type of the expense, and append it * to the appropriate list if expense_type == "TR": TRs.append (expense_amount) if expense_type = "FO": FOs, append(expense_amount) if expense_type =="CL": CLs.append (expense_amount) if expense_type = "PE": PEs.append(expense_amount) if expense_type == "ME": MEs. append(expense_amount) \# Q4: After the file processing is done: * - total up the daily receipts and add this to the daily total list \# - get the length of the daily receipts and add it to the daily count list * - get the maximum amount and add that to the daily max list \# Q5: Let's do the require calculations. \# Create a new list to store the percentages by category, and then append \# each percentage to it \# Then, calculate the daily average expenditure. \# How can you calculate the average? You need to divide every element in the * daily list by every element in the daily count list. Think about using a \# for loop and an incrementing counter together... \# Q6: Let's prepare the report. * First, show them their overall average daily expenditure * Then show the percentage they spent on each category. * Finally, let's prepare some visualizations of the data. \# Make a bar chart showing the overall percentages. \# plt,bar needs three arguments, which can be list: \# - x, the x position of the bars, \# - height, the height of the bars (in our case, the percentages) \# - tick_label, the labels the bars will have on the x-axis \# Make one line chart showing the daily totals, daily max and daily average \# Don't forget to put labels on the axes

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!