Skip to content

Instantly share code, notes, and snippets.

@versluis
Created November 5, 2016 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save versluis/3c1b06e200966438348c7e62a0fa8ae0 to your computer and use it in GitHub Desktop.
Save versluis/3c1b06e200966438348c7e62a0fa8ae0 to your computer and use it in GitHub Desktop.
denominations.py
# Calculate denominations in dollars, quarters, dimes and cents from a starting sum (in cents)
print('---------------')
amount = 439
print('Total: ', amount)
dollars =(amount-amount%100)/100
amount -=dollars*100
quarters = (amount-amount%25)/25
amount -= quarters*25
dimes = (amount-amount%5)/5
amount -= dimes*5
cents = amount
print()
print('Dollars: ', int(dollars))
print('Quarters: ', int(quarters))
print('Dimes: ', int(dimes))
print('Cents: ', int(cents))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment