Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A Python program managing a school vending machine keeps the current inventory i

ID: 3597808 • Letter: A

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, 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:

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_lst. 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:

b) Write ONE expression that uses sales_lst 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 sum() function.

Explanation / Answer

test(100)

import csv
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote