Denominations in Python

Problem Statement:

The problem of denominations in python is very easy. The user gives us a total amount and we should count the number of currency notes to exchange that total amount. For example: if we are given a total amount of 475 then we should exchange it with 4 notes of 100s, 1 note of the 50s, 1 note of 20s, and 1 note of 5s.

Code for denominations in python:

total_amount = int(input("Enter your total amount: "))

list_of_notes = [1000, 500, 100, 50, 20, 10, 5]

for i in list_of_notes:
    number_of_notes = total_amount // i
    total_amount %= i
    if number_of_notes != 0:
        print(f"The number of notes of {i} is {number_of_notes}")


code for denominations in python
output for denominations in python

Also Read:


Author: Ayush Purawr