Skip to main content

Posts

Showing posts with the label twos

Python - Calculate Money Change and Denomination

🐍  Python program to calculate change and denominations. The user enters the price and then the amount of money given. The program will figure out the change and the number of ones, twos, fives, tens, twenties, fifties, hundreds, two hundreds, and thousands to be returned. Use dictionary data type. Solution def changecalculator(bill, received):     if received > bill:         change_dic = {'thousand' : 0, 'fivehundred' : 0, 'twohundred' : 0, 'hundred' : 0, 'fifty' : 0, 'twenty' : 0, 'ten' : 0, 'five' : 0, 'two' : 0, 'one' : 0}         changeof = received - bill         rem = changeof         print(f"Amount to be returned: {rem}")         while rem > 0:             if rem >= 1000:                 change_dic['thousand'] += rem//1000                 rem = rem...