interpreter pattern class itemisa(object)def __init__(selfitem_type)self item_type item_type def evaluate(selfitem)return self item_type =item item_type class numberofitemsoftype(object)def __init__(selfnumber_of_itemsitem_type)self number number_of_items self item_type item_type def evaluate(selftab)return len([ for in tab items if item_type =self item_type]=self number class customerisa(object)def __init__(selfcustomer_type)self customer_type customer_type def evaluate(selftab)return tab customer customer_type =self customer_type class tab(object)def __init__(selfcustomer)self items [self discounts [self customer customer def calculate_cost(self)return sum( cost for in self itemsdef calculate_discount(self)return sum( for in self discountsclass item(object)def __init__(selfnameitem_typecost)self name name self item_type item_type self cost cost