Question text Case study: A small online bookstore wants to manage customer orders efficiently. Each customer can select up to three books from the available titles. The system should keep track of the customer names and the list of books they have ordered. The bookstore requires a Python program that can record customer names along with their selected books, ensure that each customer cannot order more than three books, and automatically remove any duplicate books in a customer’s order using a set. The program should also display each customer’s name together with the books they have ordered, and count and display the total number of books ordered by all customers. Sample Output: Alice ordered {'Book A', 'Book B'}Bob ordered {'Book A', 'Book B', 'Book C'}Charlie ordered {'Book C'}Total books ordered: 6 Question: Complete the Python code below by filling in the missing statements in 10 blanks so that the system works as described above. Each blank is worth 1 mark. # Step 1: Initialize lists for customer names and their orderscustomers = []orders = [] # Step 2: Function to add a customer orderdef add_order(customer_name, book_list): Answer 1 Question 27[input] book_set = Answer 2 Question 27[input] # Remove duplicates customers.Answer 3 Question 27[input] orders.Answer 4 Question 27[input] else: print(customer_name, "cannot order more than 3 books") # Step 3: Function to display all ordersAnswer 5 Question 27[input] Answer 6 Question 27[input] print(Answer 7 Question 27[input], "ordered", Answer 8 Question 27[input]) # Step 4: Function to count total books ordereddef total_books(): count = 0 Answer 9 Question 27[input] count += len(book_set) Answer 10 Question 27[input] # Step 5: Example usageadd_order("Alice", ["Book A", "Book B"])add_order("Bob", ["Book B", "Book C", "Book A"])add_order("Charlie", ["Book C", "Book C"]) # Duplicate book display_orders()print("Total books ordered:", total_books())多项填空题

题目图片

登录即可查看完整答案

我们收录了全球超50000道真实原题与详细解析,现在登录,立即获得答案。

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!