Question: Grocery apps A4p_input.csv and A4s_input.csv are two files that respectively record the purchase and sales orders of an online store. These transactions have not been
Grocery apps
A4p_input.csv and A4s_input.csv are two files that respectively record the purchase and sales orders of an online store. These transactions have not been properly sorted according to time. Please write a general program to accept the data. You should view both files using Notepad or Word, because Excel may reformat the date-time. Do NOT use the date-time import, but write your own Python codes to process the date-time column as some may be out of range. Some tips:
Use open() and readlines() to read csv files
Use split() to separate items in a string, strip() to remove spaces
Remember to convert string to integer by calling e.g. int(12) Parts of the input: A4p_input:
| date/time | item name | cost per unit | units purchased |
| ######## | watermelon | 10 | 10 |
| ######## | apple | 5 | 2 |
| ######## | durian | 20 | 3 |
| ######## | orange | 8 | 2 |
| ######## | apple | 5 | 1 |
| ######## | orange | 7 | 2 |
| ######## | watermelon | 5 | 1 |
| ######## | watermelon | 1 | 4 |
| ######## | apple | 13 | 6 |
| ######## | apple | 18 | 5 |
| ######## | watermelon | 13 | 9 |
| ######## | apple | 10 | 9 |
| ######## | apple | 2 | 2 |
| ######## | orange | 5 | 2 |
| ######## | apple | 13 | 9 |
| ######## | watermelon | 6 | 9 |
| ######## | watermelon | 16 | 2 |
| ######## | durian | 19 | 5 |
| ######## | watermelon | 12 | 10 |
A4s_input:
| date/time | item name | price per unit | units sold |
| ######## | watermelon | 17 | 4 |
| ######## | durian | 21 | 5 |
| ######## | apple | 15 | 4 |
| ######## | durian | 32 | 5 |
| ######## | durian | 12 | 1 |
| ######## | apple | 23 | 5 |
| ######## | apple | 21 | 3 |
| ######## | orange | 23 | 3 |
| ######## | durian | 32 | 1 |
| ######## | apple | 32 | 1 |
| ######## | apple | 11 | 1 |
| ######## | apple | 38 | 1 |
| ######## | durian | 33 | 3 |
| ######## | orange | 10 | 3 |
| ######## | watermelon | 26 | 5 |
| ######## | orange | 11 | 5 |
| ######## | orange | 35 | 10 |
| ######## | apple | 30 | 4 |
| ######## | watermelon | 19 | 4 |
Question:
Determine the profit margin (i.e. average profit/average cost) for each item.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
