Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def exact_change(change):
- coins = []
- def add(denomination):
- nonlocal coins, change
- full, change = int(change // denomination), int(change % denomination)
- coins.append(full)
- add(100)
- add(25)
- add(10)
- add(5)
- add(1)
- return coins
- if __name__ == '__main__':
- input_val = float(input())
- if input_val <= 0 or input_val % 100 == 0: print("no change")
- else:
- for (ns, np), c in zip(
- (('dollar', 'dollars'), ('quarter', 'quarters'), ('dime', 'dimes'), ('nickel', 'nickels'), ('penny', 'pennies')),
- exact_change(input_val)
- ):
- if c > 0:
- print(c, ns if c == 1 else np)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement