Question: NEED HELP WITH THIS PYTHON CODE Please help me find the error Problem One: The American Red Cross wants you to write a program that

NEED HELP WITH THIS PYTHON CODE

Please help me find the error

Problem One:

The American Red Cross wants you to write a program that will calculate the average pints of blood donated during a blood drive. The program should take in the number of pints donated during the drive, based on a seven hour drive period. The average pints donated during that period should be calculated and displayed. Additionally, the highest and the lowest number of pints donated should be determined and displayed. Write a loop around the program to run multiple times.

############# def main(): endProgram = 'no' print while endProgram =='no': print pints = [0]*7 totalPints = 0 averagePints = 0 highPints = 0 lowPints = 0

#functions pints = getPints(pints) totalPints = getTotal(pints, totalPints) averagePints = getAverage(totalPints, averagePints) highPints = getHigh(pints, highPints) lowPints = getLow(pints, lowPints) displayInfo(averagePints, highPints, lowPints) endProgram = raw_input('Do you want to end program? (Enter no or yes): ') while not (endProgram == 'yes' or endProgram == 'no'): print('Please enter a yes or no')

endProgram = raw_input('Do you want to end program? (Enter no or yes): ')

#getPints function def getPints(pints): counter = 0 while counter < 7: pints[counter] = input('Enter pints collected: ') counter = counter + 1 return pints

#getTotal function def getTotal(pints, totalPints): counter = 0 while counter < 7: totalPints = totalPints + pints[counter] counter = counter + 1 return totalPints

#getAverage function def getAverage(totalPints, averagePints): averagePints = float(totalPints) / 7

return averagePints #getHigh function def getHigh(pints, highPints): highPints = pints[0] counter = 1 while counter < 7: if pints[counter] > highPints: highPints = pints[counter] counter = counter + 1 return highPints

#getLow function def getLow(pints, lowPints): lowPints = pints[0] counter = 1 while counter < 7: if pints[counter] < lowPints: lowPints = pints[counter] counter = counter + 1 return lowPints

#displayInfo def displayInfo(averagePints, highPints, lowPints): print ('The average number of pints donated is', averagePints) print ('The highest pints donated is', highPints) print ('The lowest pints donated is', lowPints)

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!