From the course: Python Data Structures: Sets and Frozen Sets
Unlock this course with a free trial
Join today to access over 24,100 courses taught by industry experts.
Solution: Invoice value computation - Python Tutorial
From the course: Python Data Structures: Sets and Frozen Sets
Solution: Invoice value computation
- [Instructor] You are given with the data set just above the function definition. The data set contains details about orders, customers, products_details, and you are given with the function compute_invoice_value, which accepts customer_id and order_id as parameter. Initialize variable key with the frozenset as customer_orders dictionary, contains frozenset as the key. Initialize a variable total_bill_value = 0. Check if the key exists. Key is the customer_id and order_id pair. Check if the key exists in customer_orders dictionary. Key is the customer_id, order_id pair. If key exists in customer_orders dictionary, fetch the product_details list. Product_details list is a list of dictionary. I trade over tmp_products. Purchased_products will give dictionary that is present inside tmp_products. And in purchased_products, there is product_id, so we'll fetch product_id from purchased_products dictionary. Fetch discount value, Fetch price. Next, fetch the quantity of the product…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.