An online shop's basket holds items and their prices, and a discount code takes a percentage off the total.
Write a class Basket with:
add(name, price, qty=1) that adds an itemsubtotal() that returns the sum of price × quantity for all itemsapply_code(code) that stores a discount: "SAVE10" is 10% off and "SAVE25" is 25% off; any other code raises ValueError("unknown code")total() that returns the subtotal after the discount, rounded to 2 decimalsHow it's checked
Your code runs, then the check below runs and its printed output is compared with ours.
"SAVE10" give a total of 16.2Hints, the later steps and the answer come with Pro.
class Basket:
def __init__(self):
...