Answer to Question #235804 in Python for baby

Question #235804
Write a program to find the minimum number of notes required for the amount M
. Available note denominations are 500, 50, 10, 1.
1
Expert's answer
2021-09-10T18:48:51-0400
def min_notes(M):
    """ Function to calculate and return the minimum number of notes required
    for the amount M, given a list of denominations.
    """

    denominations = [500, 50, 10, 1]
    remainder = M
    notes = 0
    for denom in denominations:
        notes = notes + (remainder // denom)
        remainder = remainder % denom


    return notes


# Display outcome of function call
print(min_notes(562))

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