# Insurance.py # # This program is a reporting tool used each week to determine # which members of "the Family" deserve praise and who needs some # "encouragement." # # When the program runs, it asks for the names of all of the "salesmen" # and the amounts of "insurance premiums" they have collected. After the # last associate has been processed, the user enters "END" for the name, and # the program reports the maximum, minimum values and associates who attained them. # # Programmer: Garry Gambino # Date Written: Friday 13 October 2011 # def insurance ( ): maxAmt = 0.0 minAmt = 999999999.99 maxCollector = "No one" minCollector = "No one" count = 0 total = 0.0 report = "\n\n\n==== The Family Insurance Winner and Loser Report ====\n\n" nextCollector = raw_input ("Enter name of next associate (END to finish): ") while nextCollector != "END": nextAmt = input ("Enter amount collected by " + nextCollector + ": " ) if nextAmt > maxAmt: # this is the new max maxAmt = nextAmt maxCollector = nextCollector if nextAmt < minAmt: # this is the new min minAmt = nextAmt minCollector = nextCollector count = count + 1 total = total + nextAmt # # add this associate's info to the report # report = report +nextCollector + " $ %10.2f"%nextAmt + "\n" nextCollector = raw_input ("Enter name of next associate (END to finish): ") # end while if count > 0: # there's something to report print report print "\nTotal Collections: $%10.2f"%total print "Average: $%10.2f"%round(total/count,2) print "\n\nThis week's winner is " + maxCollector + \ " who collected $ %8.2f"%maxAmt + " in premiums\n" print "This week's loser is " + minCollector + \ " who only collected $ %8.2f"%minAmt + " in premiums", if minAmt < maxAmt * 0.2: # real trouble for loser below 20% of winner print "--We'll miss him.\n\n" else: print "--We hope he does better next time!" insurance( )