基础题目信息: # Import the required module
import csv
# Define the field names
fields = ['item', 'price', 'category']
# Define the data rows
rows = [ ['Chicken Parmigiana', 19.99, 'Main'], ['Fish and Chips', 18.99, 'Main'], ['Margherita Pizza', 15.99, 'Main'], ['Caesar Salad', 9.99, 'Starter'], ['Garlic Bread', 6.99, 'Starter'], ['Tiramisu', 7.99, 'Dessert'], ['Cheesecake', 6.99, 'Dessert'],
]
# Create a CSV file and write the data rows
with open('menu.csv', 'w', newline='') as csvfile: writer = csv.writer(csvfile) writer.writerow(fields) writer.writerows(rows)
问题:
-
Display the data in a table (or table-like) format.
-
Calculate the average rating for each menu item.
-
Calculate the total sales for each day of the week.
-
Determine the most popular menu item based on customer ratings.
-
You will have to modify this code to add ratings, number of items sales per week, customer ratings for each item, and any other information you may require achieving the above tasks.