Could someone lend me their brain? :D I thought I had most of it done, until I got an error saying that my 'calcAverage' definition was not defined.. x.x here is the prompt for the program:
Write a program that asks the user how many pumpkin weights they have, and then reads that many pumpkin weights, printing each weight with a comment (heavy is 70 pounds or higher, light is below 50, normal is everything inbetween), averages them, and displays the average with three decimal places. Use functions, one of which must be calcAverage(totalWeight, numPumpkins) to average the input values.
def main(): intro() pumpkinData() calcAverage(totalWeight, numPumpkins) printResults(numPumpkins, avgWeight) main() def intro(): print "Program to calculate the average of a" print "group of pumpkin weights." print "You will be asked to enter the number of" print "pumpkins, followed by each pumpkin weight." print "Written by Kristy Barner." print def pumpkinData(): numPumpkins = input("Enter the number of pumpkins: ") print print totalWeight = 0 count = 0 for i in range(numPumpkins): count = count + 1 pumpkinWeight = input("Enter the weight for pumpkin "+str(count)+": ") totalWeight = total + pumpkinWeight if pumpkinWeight < 50.000: print str(pumpkinWeight)+" is light" else: if pumpkinWeight < 70.000: print str(pumpkinWeight)+" is normal" else: print str(pumpkinWeight)+" is heavy" return numPumpkins return totalWeight def calcAverage(totalWeight, numPumpkins): avgWeight = float(totalWeight) / float(numPumpkins) return avgWeight def printResults(numPumpkins, avgWeight): print "The average weight for "+str(numPumpkins)+" is "+str(avgWeight)
Thanks very much in advance!!