The problem I am facing is commented in the code. Thanks for any help in 
advance.===============================================================================================================#15
 Change Return Program
#The user enters a cost and then the amount of money given. You should write a
#program that works out what denominations of change should be given in pounds, 
50p,
#20p, 10p etc.#to do this the programme needs to divide the change ammount by 
1.00 then 0.50 then 0.20 untill it reaches zero#Extensions:#1. The program will 
figure out the change for the American currency and the number
#of quarters, dimes, nickels, pennies needed for the change
#2. Make an automatic testing part of your program where it automatically 
generates a
#random price and an amount that you give the cashier. It then works out what 
change to
#give, and then tests that your program works by adding the change back onto 
the price of
#the item to prove your program works. It should flag an error if there are 
problems.
cost_of_item = int(float(input("how much money does the item 
cost?")))money_given = int(float(input("How much money is given?")))change = 
(money_given) - (cost_of_item)


#def coin_return(amount):coinvalues = {'£1':1.00, '50p':0.50,              
'20p': 0.20, '10p': 0.10,              '5p': 0.05, '2p': 0.02,              
'1p': 0.0}
while change != 0:    coinvalues = {'£1':1.00, '50p':0.50,                  
'20p': 0.20, '10p': 0.10,                  '5p': 0.05, '2p': 0.02,              
    '1p': 0.0}    answer = []    for coin_name, coin_value in coinvalues:       
 #take the maximum value in the dictionary that is not above the variable       
 #"change" and then append it into the answer list.                       
###################################################################            
# I want to take the max value in the dictionary "coinvalues"     #            
# that is the same as or lower than the variable "change".        #            
# I have no Idea how to search through the coinvalues dictionary  #            
# and find the value that is highest but does not exceed the      #             
# value held in the variable "change".                            #            
###################################################################

==========================================================================================================
              

                                          
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to