human
Solve in Python:
# Task
Follow the instructions in each failing test case to write logic that calculates the total price when ringing items up at a cash register.

# Purpose
Practice writing maintainable and extendable code. 

# Intent
This kata is meant to emulate the real world where requirements change over time. This kata does not provide a specification for the final end-state up front. Instead, it walks you through a series of requirements, modifying and extending them via test cases as you go. This kata is about the journey, not the destination. Your ability to write maintainable and extendable code will affect how difficult this kata is. 

# Provided Utility Function
You may use the following preloaded function:
```python
get_price(item)
"""Accepts a str specifying an item. Returns the price of
the item (float) or raises a KeyError if no price is available.

Example: 

    >>> get_price(apple)
    0.4
"""
```

# Acknowledgement
Inspired by http://codekata.com/kata/kata01-supermarket-pricing/. To get the most benefit from this kata, I would recommend visiting that page only after completing, not before.
 Give me a the Python program you requested?
assistant
#Here is the Python program you requested.

import re
class Checkout(object):
    def __init__(self,sales={}):
        self.total=0.0
        self.items={}
        self.sales={}
        self.buyget={}
        self.off={}
        for k,v in sales.items():
            if 'for' in v:
                x,y=v.split('for')
                self.sales[k]=(int(x),float(y))
            elif 'buy' in v:
                x,y=v.split('get')
                self.buyget[k]=(int(x.replace('buy','')),int(y))
            elif 'off' in v:
                x,y=v.split('off')
                self.off[k]=(float(x),int(y.replace('ormore','')))
    
    def scan(self,item,q=1):
        self.items[item]=self.items.get(item,0)+q
        self.total+=get_price(item)*q
        if item in self.sales:
            if self.sales[item][0]<=self.items[item]:
                x=self.items[item]//self.sales[item][0]
                self.total+=x*self.sales[item][1]-x*self.sales[item][0]*get_price(item)
                self.items[item]%=self.sales[item][0]
        elif item in self.buyget:
            x,y=self.buyget[item]
            if self.items[item]>=x+y:
                z=self.items[item]//(x+y)
                self.total-=z*y*get_price(item)
            self.items[item]%=(x+y)
        elif item in self.off:
            if self.items[item]==self.off[item][1]:
                self.total-=self.off[item][0]
        self.total=round(self.total,2)