Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Oct 1st, 2013  |  syntax: Python  |  size: 0.38 KB  |  views: 56  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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)