Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Note: Quantity and Profit should be brought forward to the following month, etc.] Assume that the store begins with no stocks, and a stock quantity

image text in transcribed

[Note: Quantity and Profit should be brought forward to the following month, etc.]

Assume that the store begins with no stocks, and a stock quantity increases after a purchase. If the current quantity in the store is not enough to serve the requested sales order, then that particular order will be rejected/ignored. Profit is defined as the amount of money obtained from selling the item (e.g. apple) minus the amount that is used to purchase that particular stock.

Parts of the input:

A4p_input:

date/time, item name, cost per unit, units purchased 2017-01-02 10:56:54, watermelon,10,10 2017-01-02 11:23:25,apple,5,2 2017-01-02 12:21:59, durian,20,3 2017-01-03 13:14:55,orange,8,2 2017-01-06 15:45:02, apple,5,1 2017-01-06 17:10:52, orange,7,2 2017-01-07 18:41:59, watermelon,5,1 2017-01-07 19:20:51, watermelon,1,4 2017-01-08 20:55:51, apple,13,6 2017-01-11 00:05:37, apple,18,5 2017-01-18 04:29:49, watermelon,13,9 2017-01-21 06:59:22, apple,10,9 2017-01-22 07:10:58, apple,2,2 2017-01-24 09:06:07, orange,5,2 2017-01-24 10:10:02, apple,13,9 2017-01-26 11:58:55, watermelon,6,9 2017-01-28 13:52:42, watermelon,16,2 2017-01-29 14:00:32, durian,19,5 2017-02-02 16:49:46, watermelon,12,10 2017-02-03 16:49:59, durian,6,1 2017-02-04 19:05:49, durian,9,20

A4s_input

date/time, item name,price per unit, units sold 2017-01-04 13:59:57, watermelon,17,4 2017-01-05 14:54:44, durian,21,5 2017-01-06 16:37:43, apple,15,4 2017-01-07 17:30:46, durian,32,5 2017-01-07 17:58:48, durian,12,1 2017-01-07 19:37:50, apple,23,5 2017-01-07 19:40:26, apple,21,3 2017-01-07 19:44:08, orange,23,3 2017-01-08 20:04:55, durian,32,1 2017-01-09 21:42:23, apple,32,1 2017-01-09 22:24:25, apple,11,1 2017-01-09 23:22:00, apple,38,1 2017-01-11 00:24:04, durian,33,3:

A4 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) (a) Show the earliest/oldest 3 date-time stamps of the purchase transactions. oldest 3: 2017-01-02 10:56:54 2017-01-02 11:23:25 2017-01-02 12:21:59 (b) Show oldest date-time on the purchase file, and decompose it into year and month, ignoring the rest. oldest: 2017-01-02 10:56:54 Year: 2017 Month: 1 (c) Display the year and month of all purchases without duplicates. All year-month pairs: 2017 1 2017 2 2017 3 : 2018 5 2018 7 (d) Create a program which prints out the stock quantity and the profit earned at the end of every month in the following format. Assuming the stock is initially empty and profit=$0. Year 2017 Month 1 apple quantity= 14 profit= 46 durian quantity= 5 profit= -99 orange quantity= 1 profit= 89 watermelon quantity= 5 profit= 397 Year 2018 Month 7 apple : quantity= ? profit= ? durian : quantity= ? profit= ? orange : quantity= ? profit= ? watermelon : quantity= ? profit= ? (e) Determine the profit margin (i.e. average profit/average cost) for each item

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions