SHARE
TWEET

Untitled

a guest Oct 1st, 2013 56 Never
  1. #!/usr/bin/python
  2.  
  3. PRICE=123.45
  4. PAID=1300.0
  5.  
  6. change=PAID-PRICE
  7.  
  8. # Find largest denomination
  9. c=-3
  10. while True:
  11.     if int(change/pow(10,c)) == 0:
  12.         break
  13.     c += 1
  14.  
  15. while change>0:
  16.     c-=1
  17.     denomination = pow(10,c)
  18.     bills = int(change/denomination)
  19.     print "%d-%fs" % (bills,denomination)
  20.     change -= bills*denomination
  21.     change = round(change,2)
RAW Paste Data
Top