1. Question 1.
Import the csv file in pandas and save it as a dataframe. Then, write a code that returns: (1) the
first 10 and last 10 rows; and (2) the number of rows and columns in the data set. Discuss what
the code shows you about the data set.
Output :
2. Question 2.
Write a code that returns: (1) the distribution of sales outlets (including a count of each outlet
type and a bar chart); (2) the minimum and maximum transaction_id; (3) the minimum,
maximum and average customer_id; and (4) the distribution of products in bought in store (yes
or no) using a pie chart.
Code:
Output:
3. Question 3.
You discover that the variable unit_price was incorrectly recorded. Create a new variable
unit_price_corrected where you add 1.50 to unit_price for the first 100 items, and you subtract
1.50 from the unit price for the remaining items in the data set. Then, calculate and compare the
average of unit_price and unit_price_corrected.
Code:
Output:
4. Question 4.
The coffee shop’s management wants to find out which of the outlets has the highest revenue.
Calculate the total revenue for each of the outlets. Remember that total revenue will be
unit_price_corrected multiplied by quantity. Also, present your calculations using a line graph.
Explain what you found and what the chart shows.
Code:
Output:
5. Question 5.
The coffee shop’s management wants to find out how the staff are doing in terms of sales. For
each of the staff ids, calculate the total product units sold and the total revenue sold. Provide two
bar charts (one for total product units, one for total revenue) by staff id, and interpret your
Findings.
Code:
Output:
6. Question 6.
Develop one question yourself that can be answered with the information included in this
dataset. Write the code to answer the question, and include a visualization.
7. Question 7.
Develop one question yourself that can be answered with the information included in this
dataset. Write the code to answer the question, and include a visualization.
8. Part 2
You are hired to develop an online management system for a cafe. This program will be used by
the café admins and will help them manage online orders. Use a function to develop a program
with the following features:
1. Allow the café admin to enter the menu items until the user enters quit to stop. The list
should include a minimum of 10 items. For example: main_categories = [Americano,
Espresso, Cheese sandwich]
2. Use the main menu list you created in step 1 to create a dictionary that should contain the
price of each of the menu items with their respective cost. For example: items_price=
{“Americano”: 13, “Espresso”: 9, “Cheese sandwich”:15}
3. Use the main menu list you created in step 1 to create another dictionary that should
contain the quantity of each menu item. items_quantity={“Americano”: 50, “Esspresso”:
30, “Cheese sandwich”:10}
4. Use the main menu list you created in step 1 to create another dictionary that allows the
cafe admin to record the rating received from customers on menu items. The ratings are
scored on a scale from 1 to 5, with 5 indicating the maximum customer satisfaction. For
example: items_rating = {“Americano”: 4, “Esspresso”: 1, “Cheese sandwich”:5}
Your function should return the following data structures separately:
1. The dictionary that includes all entries.
2. A list named satisfied_item, which includes the items with satisfaction of 3 or higher.
3. A list named highprice_item, which includes the items with price above 10 .
4. A list named few_items, which includes the items with quantity less than 5.
9. Algorithm :
• To keep track of menu items and their pertinent details, initialize a
dictionary called menu_items, ensuring it starts with no entries.
• To keep track of items meeting satisfaction criteria of 3 or above, initialize
an empty list called satisfied_items.
• To keep track of pricey items, initiate an empty list with the name
highprice_items, and only store objects that surpass a cost of 10.
• To hold the items that have a quantity less than 5, it is necessary to make
an empty list named few_items.
• To give the café admin the ability to type in menu items, initiating a loop
may be necessary.
• Prompt the café admin for the menu item's name within the loop. If they
type in "quit," leave the loop.
• Enter and store the menu item price in a variable, prompting the café adm
• Store the quantity of a menu item entered by the café admin in a variable
through a prompt.
• Enter the café admin to rate their satisfaction with the menu item on a
scale of 1 to 5 and then save it in a variable.
• Include the satisfaction rating, quantity, and price of the menu item within
the menu_items dictionary as a key-value pair.
• Append the content to the satisfied_items list, given that the rating exceeds
3.
• The menu item should be added to the highprice_items list if it exceeds 10
in price.
• List the menu item on the few_items list if the amount is below 5.
• Enter "quit" to exit the process, and repeat steps 6-13 until then.
• List the satisfied_items, highprice_items, few_items, and the menu_items
dictionary.