Python

profiledfdffd14
donutMod.py

def getSales(): dicDonuts = {} lstMonths = ("January","February") ## ,"March","April","May","June","July","August","September","October","November","December") for strMonth in lstMonths: fltDonutSales = float(input("What are sales for month " + strMonth + " ? ") or "20") dicDonuts[strMonth] = fltDonutSales return dicDonuts def calcDonutSales(dicDonuts): TotDonuts = 0 AveDonuts = 0.0 fltMaxAmt = 0 dicDonutStat = {} strBestMnt = "" for strMonth in dicDonuts: TotDonuts = TotDonuts + dicDonuts[strMonth] if dicDonuts[strMonth] >= fltMaxAmt: fltMaxAmt = dicDonuts[strMonth] strBestMnt = strMonth else: None AveDonuts = TotDonuts/len(dicDonuts) dicDonutStat["Total"] = TotDonuts return TotDonuts,AveDonuts,strBestMnt,fltMaxAmt def printOutput(TotDonuts,AveDonuts,strBestMnt, fltMaxAmt): print(f"The total donut sales for this year are ${TotDonuts:,.2f}") print(f"We sold about ${AveDonuts:,.2f} a month") print("The month with the largest total was",strBestMnt,f"with a total of ${fltMaxAmt:,.2f}") def main(): dicDonuts = getSales() TotDonuts,AveDonuts,strBestMnt,fltMaxAmt = calcDonutSales(dicDonuts) printOutput(TotDonuts,AveDonuts,strBestMnt, fltMaxAmt) main()