Answer to Question #210970 in Python for Ravichandrasekhar

Question #210970

Given an amount, write a program to find a minimum number of currency notes of different denominations that sum to the given amount. Available note denominations are 1000, 500, 100, 50, 20, 5, 1.

For example, if the given amount is 8593, in this problem you have to give the minimum number of notes that sum up to the given amount. Since we only have notes with denomination 1000, 500, 100, 50, 20, 5 and 1, we can only use these notes.

1000:8

500:1

100:0

50:1

20:2

5:0

1:3


1
Expert's answer
2021-06-27T14:11:20-0400
nominals = (1000, 500, 100, 50, 20, 5, 1)
amount = int(input('amount = '))
output = {}
for n in nominals:
	output[n] = amount // n
	amount %= n
for k, v in output.items():
	print(k, v, sep=':')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS