If you really want to learn, learn what is not studious, if really want to learn the acme of Python, almost what they want to do, it is necessary to make perseverance, persist.
Then continue to update the Python Exercise 2, by updating the previous exercises to learn a lot of things
1. take any amount less than US $1, and then calculate what kinds of coins can be exchanged, how many are there? Coins have 1 cents, 5 cents, 10 cents, 25 cents 4 kinds, such as 0.76 dollars for 3 25 cents, 1 pieces 1 cents
1 #Encoding=utf-82 __author__='Heng'3 fromCopyImportDeepcopy#when you want to change the dictionary, remember to deep copy, otherwise the original dictionary will be affected4Money = Float (raw_input ("Please enter the money (dollar):"))5money = Int (100*Money )6Moneydic = {25:0,10:0,5:0,1: 0}7 forKeyinchMoneydic:8 ifMoney >=Key:9Moneydic[key] = Int (money/key)Tenmoney = Int (money%key) OneMoneydic1 = Deepcopy (moneydic)#This is a deep copy . A forKeyinchMoneydic: - ifMoneydic[key] = =0: - delMoneydic1[key]#because of deep replication, the iterative object changes are not reported when a for loop iteration is made the - forKeyinchMoneydic1: - Print("%s The%s cent"% (Moneydic1[key],key)),
Python exercises 2