Build a shopping cart management system, starting simple with requirements added incrementally.
Asked in the live coding stage. Unit tests and TDD expected.
Implement shopping_cart(operations). Each operation is a dictionary with action add, set_quantity, remove, or total. add increases an item's quantity and replaces its unit price with the supplied price. set_quantity replaces the quantity, removing the item when the quantity is zero. Mutations append None; total appends the sum of price multiplied by quantity for all items. Return the results list.
def shopping_cart(operations):