interpreter pattern def evaluate(selftab)return self expression evaluate(tabor self expression evaluate(tabclass percentagediscount(object)def __init__(selfitem_typepercentage)self item_type item_type self percentage percentage def calculate(selftab)return (sum([ cost for in tab items if item_type =self item_type]self percentage class cheapestfree(object)def __init__(selfitem_type)self item_type item_type def calculate(selftab)tryreturn min([ cost for in tab items if item_type =self item_type]exceptreturn class todayis(object)def __init__(selfday_of_week)self day_of_week day_of_week def evaluate(selftab)return datetime datetime today(weekday(=self day_of_week name class timeisbetween(object)def __init__(selffrom_timeto_time)self from_time from_time self to_time to_time def evaluate(selftab)hour_now datetime datetime today(hour minute_now datetime datetime today(minute