|
| 1 | +#Create a data structure with 2 elements (Name, Dollar Amount Donated) |
| 2 | + |
| 3 | +donor_list = ['Mick Jagger','$500.00', |
| 4 | +'Jimmy Page','$200.00', |
| 5 | +'Robert Plant','$100.00', |
| 6 | +'Roger Daltry','$400.00', |
| 7 | +'Pete Townsend','$250.00', |
| 8 | +'Eric Clapton','$500.00', |
| 9 | +'Mick Jagger','$700.00', |
| 10 | +'Eric Clapton','$200.00', |
| 11 | +'Pete Townsend','$950.00', |
| 12 | +'Robert Plant','$800.00', |
| 13 | +'Mick Jagger','$400.00', |
| 14 | +'Roger Daltry','$750.00', |
| 15 | +'Pete Townsend','$750.00', |
| 16 | +'Eric Clapton','$900.00', |
| 17 | +'Mick Jagger','$500.00', |
| 18 | +'Robert Plant','$800.00', |
| 19 | +'Roger Daltry','$600.00',] |
| 20 | + |
| 21 | +def write_thk_letrs(user_input2): |
| 22 | +#Write a letter thanking a donor# |
| 23 | + |
| 24 | + print ("Dear %s. \n\nThank you for your generous contribution !\n\nYou Rock !\n\n" % (user_input2)) |
| 25 | + return main() |
| 26 | + |
| 27 | + |
| 28 | +def thanks_note(): |
| 29 | + user_input2 =raw_input('Please provide the full name of the donor, or type "list for a list of donors" :\n\n') |
| 30 | + |
| 31 | + if user_input2 == 'list': |
| 32 | + tmp_list1= [] |
| 33 | + tmp_list2= [] |
| 34 | + i = "" |
| 35 | + tmp_list1 = donor_list[0::2] |
| 36 | + for i in tmp_list1: |
| 37 | + if i not in tmp_list2: |
| 38 | + tmp_list2.append(i) |
| 39 | + for x in tmp_list2: |
| 40 | + print ("\n" + x + "\n") |
| 41 | + return add_donor() |
| 42 | + |
| 43 | + else: |
| 44 | + for d_name in donor_list: |
| 45 | + if d_name == user_input2: |
| 46 | + return write_thk_letrs(user_input2) |
| 47 | + |
| 48 | + |
| 49 | +def add_donor(): |
| 50 | + user_input2 =raw_input('Please provide the full name of the donor, or type "list for a list of donors" :\n\n') |
| 51 | + for d_name in donor_list: |
| 52 | + |
| 53 | + if d_name != user_input2: |
| 54 | + break |
| 55 | + |
| 56 | + while True: |
| 57 | + user_input3 = raw_input("\n" + user_input2 + " is a new donor,and can be added to the donor list.\n " " \nWould you like" |
| 58 | + " to make a donation for " + user_input2 + " ?\n\nPlease answer 'Yes' or 'No' ") |
| 59 | + |
| 60 | + if user_input3 == "No": |
| 61 | + main() |
| 62 | + |
| 63 | + if user_input3 == "Yes": |
| 64 | + break |
| 65 | + |
| 66 | + while True: |
| 67 | + user_input4 = raw_input('Enter the donation amount \n\n ') |
| 68 | + |
| 69 | + #if user_input3 == 'menu': |
| 70 | + #return 'menu' |
| 71 | + try: |
| 72 | + user_input4 = float(user_input4) |
| 73 | + break |
| 74 | + |
| 75 | + except ValueError: |
| 76 | + print 'Specified Donations must be a in a numeric format, renter amount.' |
| 77 | + |
| 78 | + |
| 79 | + user_input4 = "$"+str(user_input4) |
| 80 | + donor_list.extend([user_input2, user_input4]) |
| 81 | + write_thk_letrs(user_input2) |
| 82 | + |
| 83 | +def donor_report(): |
| 84 | + |
| 85 | + tmp_list3= [] |
| 86 | + tmp_list4= [] |
| 87 | + user_input5 ="" |
| 88 | + i = "" |
| 89 | + tmp_list3 = donor_list[0::2] |
| 90 | + |
| 91 | + print("\n\nDonor Name Total Amount Donated Number of Donations Average Donation\n" ) |
| 92 | + for i in tmp_list3: |
| 93 | + if i not in tmp_list4: |
| 94 | + tmp_list4.append(i) |
| 95 | + for x in tmp_list4: |
| 96 | + print ("\n" + x + "\n") |
| 97 | + |
| 98 | +def main(): |
| 99 | + |
| 100 | + |
| 101 | + while True: |
| 102 | + user_input1 = '' |
| 103 | + user_input2 = '' |
| 104 | + user_input3 = '' |
| 105 | + user_input4 = '' |
| 106 | + user_input4 = '' |
| 107 | + |
| 108 | + user_input1 = raw_input('Welcome to the Donations Support Program\n\n' |
| 109 | + 'Please enter a 1 to Send a Thank You Note \n\n' |
| 110 | + 'Please enter a 2 to Create a Report \n\n' |
| 111 | + 'Please enter a 3 to exit this project \n\n') |
| 112 | + |
| 113 | + |
| 114 | + if user_input1 == '1': |
| 115 | + #print("Send a Thank You Note") |
| 116 | + return thanks_note() |
| 117 | + |
| 118 | + |
| 119 | + if user_input1 == '2': |
| 120 | + #print("Create a Report") |
| 121 | + return donor_report() |
| 122 | + |
| 123 | + |
| 124 | + if user_input1 == '3': |
| 125 | + print ("Exiting this Program") |
| 126 | + break |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | +if __name__ == '__main__': |
| 131 | + main() |
| 132 | + |
| 133 | + |
0 commit comments