Python, first time using Decimal and quantize
Question: I was just wondering if anybody had any input on how to improve this code. My
goal is for it to be as pythonic as possible since I'm trying to really learn
python well. This program works fine, but if you see anything that you think
could be done to improve (not major changes, just basic "Im new to python"
stuff) this program please let me know.

    
    
    #!/usr/bin/python
    from decimal import *
    
    
    print "Welcome to the checkout counter!  How many items are you purchasing today?"
    
    numOfItems = int(raw_input())
    
    dictionary = {}
    
    for counter in range(numOfItems):
    
        print "Please enter the name of product", counter + 1
        currentProduct = raw_input()    
    
        print "And how much does", currentProduct, "cost?"
        currentPrice = float(raw_input())
    
        dictionary.update({currentProduct:currentPrice})
    
    print "Your order was:"
    
    subtotal = 0
    for key, value in dictionary.iteritems():
    
        subtotal = subtotal + value
        stringValue = str(value)
        print key, "$" + stringValue
    
    tax = subtotal * .09
    total = subtotal + tax
    total = Decimal(str(total)).quantize(Decimal('0.01'), rounding = ROUND_DOWN)
    
    stringSubtotal = str(subtotal)
    stringTotal = str(total)
    
    print "Your subtotal comes to", "$" + stringSubtotal + ".", " With 9% sales tax, your total is $" + stringTotal + "."
    
    print "Please enter cash amount:"
    cash = Decimal(raw_input()).quantize(Decimal('0.01'))
    
    change = cash - total
    stringChange = str(change)
    
    print "I owe you back", "$" + stringChange
    
    print "Thank you for shopping with us!"
    


Answer:   1. Call the product dictionary "products" or some similarly descriptive name, instead of just "dictionary"
  2. Generally, if you are iterating over a range, use `xrange` instead of `range` for better performance (though it's a very minor nitpick in an app like this)
  3. You can use `subtotal = sum(dictionary.itervalues())` to quickly add up all the item prices, without having to use the loop.
  4. You should definitely use Decimal throughout to avoid inaccuracies due to `float`.
  5. You can use a formatting string like `'%.2f' % value` (old-style format) or `'{:.2f}' .format(value)` (new-style format) to print out values with two decimal places.
  6. The tax value should be a constant, so it can be changed easily (it's used in two places, once for the calculation and once for the display).

