Question: A Python program managing a school vending machine keeps the current inventory in a list variable called inventory with tuples (product str, stock int,sold int

 A Python program managing a school vending machine keeps the current

A Python program managing a school vending machine keeps the current inventory in a list variable called inventory with tuples (product str, stock int,sold int price float). product str is the name of the product; stock int is the quantity still in stock (an int), sold int is the quantity sold (int), and price_float is the sell price a float number For example, the inventory list at some time may look like this: ( Snickers Bar', 20, 3e, 1.5), (Tic Tac, 18, 10, 1.0), Cheetos', 43, 15, 2.8)1 a) Write ONE expression with a list comprehension that returns a list with the total sales $$ amount for each product. Name the returned list sales_ Ist. The total sale for a product tuple is sold int price_float. For the example inventory list above, the desired list with product sales is: ('Snickers Bar', 45.0), ('Tic Tac, 10.0), ('Cheetos', 30.0)1 b) Write ONE expression that uses sales Ist from part a) with a list comprehension that returns the total sales across all products. For the products in the above example, the total sales figure is 85.0. Hint: use the builtin sum0 function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!