diff_inventory(old, new) comparing two stock dicts (product -> quantity). Return a dict with three keys: "added" (products in new but not old, mapped to their new quantity), "removed" (products in old but not new, mapped to their old quantity), and "changed" (products in both with different quantities, mapped to a tuple (old_qty, new_qty)).diff_inventory({'pen': 10, 'bag': 5, 'mug': 2}, {'pen': 10, 'bag': 8, 'cup': 4}){'added': {'cup': 4}, 'removed': {'mug': 2}, 'changed': {'bag': (5, 8)}}pen unchanged so excluded everywhere; bag quantity changed; mug removed; cup added.
Use set operations on `old.keys()` and `new.keys()` to find added/removed key sets.
For shared keys, compare quantities and collect the differing ones.