Prototype: implement change_due(price, paid). Both arguments must be nonnegative integers, excluding booleans. Return paid - price when payment is sufficient; otherwise raise ValueError. Invalid values also raise ValueError.
Final: implement VendingMachine(products), where products is a list of (code, price, stock) tuples. Codes must be unique nonempty strings, price a positive integer, and stock a nonnegative integer; booleans are invalid numeric inputs. Empty inventory is valid. Copy the supplied inventory. Invalid inventory raises ValueError.
insert(amount) accepts a positive integer, adds it to credit, and returns the new credit. balance() returns current credit. select(code) returns {"code": code, "change": credit_before - price} on success, decreases that item's stock by one, and sets credit to zero. Unknown codes raise KeyError. A known item with zero stock or insufficient credit raises ValueError. Failures leave all state unchanged. refund() returns current credit and resets it to zero; repeated refunds return zero. inventory() returns a fresh dictionary mapping each code to a fresh {"price": price, "stock": stock} dictionary. There is no restock operation, and instances must be independent.
Complete the starter code, then run the checks.
Results and errors will appear here.