Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program that calculate and summarize the sales of every day and finds out who are the best employee who made more profits.

Write a Python program that calculate and summarize the sales of every day and finds out who are the best employee who made more profits.

For simplicity: We assume that the program works for only two days and for only two employees. i.e. the program collects and summarize the sales of only two days for only two employees

The program accepts undefined number of sales for each employee.

For example: You could assume in the first day the first employee made 5 sales and the second employee made 3 sales. Similarly, in the second day you can assume any random number of sales for each employee. The amount of each sales also can be chosen randomly as an integer number.

The program starts collecting data in the following order:

  1. Day 1 Employee 1 sales then
  2. Day 1 Employee 2 sales then
  3. Day 2 Employee 1 sales then finally
  4. Day 2 Employee 2 sales

User can move from (a) to (b) to (c) and finally to (d) by entering 0 (zero) value. The last entered zero will print the summary. The summary shows total sales per day and total sales per employee, and best employee for each day, that is the employee who achieves more sales in amount of money, not in number of sales.

Assume that the total sales would never be the same for both employee, i.e. one of the employee always sells more than the other. Either the first employee will sell more than the second employee, or the second employee will sell more than the first employee.

Also, assumes that the user doesnt do any mistakes in the entry of the data.

The main function should start with the following:

sales={

'd1':{

'e1':{'sls':[]},

'e2':{'sls':[]}},

'd2':{

'e1':{'sls':[]},

'e2':{'sls':[]}}}

It is the declaration of sales dictionary. As you can see, it is a multidimensional dictionary that can contain the sales of two employees in two days.

The program should use loops to produce the results of totals and winner employee.

For example:

Assume we have the following dictionary:

sales={d1:2, d1:3}

Then finding the total of sales as follows is not accepted:

Sales = {'d1':2, 'd2':3}

TotalSales = sales['d1'] + sales['d2']

The accepted form of solution to find the total sales must use loops as shown below or in a similar way as long as it uses loops:

TotalSales = 0

for k, v in sales.items():

TotalSales += v

Similar to the example above, the program should use loops to produce the results of total per employee and the total per day, and the winner employee.

You must use loops.

Below is an example of how the program runs:

Enter a sale in d1 for e1 or 0 to move to next employee or day: 1

Enter a sale in d1 for e1 or 0 to move to next employee or day: 2

Enter a sale in d1 for e1 or 0 to move to next employee or day: 3

Enter a sale in d1 for e1 or 0 to move to next employee or day: 4

Enter a sale in d1 for e1 or 0 to move to next employee or day: 5

Enter a sale in d1 for e1 or 0 to move to next employee or day: 0

Enter a sale in d1 for e2 or 0 to move to next employee or day: 6

Enter a sale in d1 for e2 or 0 to move to next employee or day: 1

Enter a sale in d1 for e2 or 0 to move to next employee or day: 2

Enter a sale in d1 for e2 or 0 to move to next employee or day: 0

Enter a sale in d2 for e1 or 0 to move to next employee or day: 4

Enter a sale in d2 for e1 or 0 to move to next employee or day: 5

Enter a sale in d2 for e1 or 0 to move to next employee or day: 0

Enter a sale in d2 for e2 or 0 to move to next employee or day: 7

Enter a sale in d2 for e2 or 0 to move to next employee or day: 8

Enter a sale in d2 for e2 or 0 to move to next employee or day: 9

Enter a sale in d2 for e2 or 0 to move to next employee or day: 0

Summary of the sales:

Employee1 Employee2 total Winner

----------------------------------------------

Day1 15 9 24 Emp 1

Day2 9 24 33 Emp 2

----------------------------------------------

Total 24 33

Note: the above run of the program is an example. The program should be able to work with random number of sales and random amount of money for each sale. Also, it should print the correct totals and winners of highest sales per day.

The program should use the exact names suggested in the given dictionary and in the given example. And the program should produce the same text used in the example above. Notice the spaces and insert the proper newlines as illustrated in the example.

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

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions

Question

Give an example that illustrates double counting.

Answered: 1 week ago

Question

Connect with your audience

Answered: 1 week ago