Advertisement
biswasrohit20

dime

Apr 4th, 2021
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. def exact_change(user_total):
  2. num_dollars = user_total // 100
  3. user_total %= 100
  4. num_quarters = user_total // 25
  5. user_total %= 25
  6. num_dimes = user_total // 10
  7. user_total %= 10
  8. num_nickels = user_total // 5
  9. user_total %= 5
  10. num_pennies = user_total
  11. return(num_dollars, num_quarters, num_dimes, num_nickels, num_pennies)
  12. if __name__ == '__main__':
  13. input_val = int(input())
  14. num_dollars, num_quarters, num_dimes, num_nickels, num_pennies = exact_change(input_val)
  15.  
  16.  
  17. if input_val <=0:
  18. print('no change')
  19.  
  20. else:
  21. if num_dollars > 1:
  22. print('%d dollars' % num_dollars)
  23. elif num_dollars == 1:
  24. print('%d dollar' % num_dollars)
  25.  
  26. if num_quarters > 1:
  27. print('%d quarters' % num_quarters)
  28. elif num_quarters ==1:
  29. print('%d quarter' % num_quarters)
  30.  
  31. if num_dimes > 1:
  32. print('%d dimes' % num_dimes)
  33. elif num_dimes == 1:
  34. print('%d dime' % num_dimes)
  35.  
  36. if num_nickels > 1:
  37. print('%d nickels' % num_nickels)
  38. elif num_nickels == 1:
  39. print('%d nickel' % num_nickels)
  40.  
  41. if num_pennies >1:
  42. print('%d pennies' % num_pennies)
  43. elif num_pennies ==1:
  44. print('%d penny' % num_pennies)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement