# HELP !! can someone take a look at this and see what i am doing wrong.

 donald goggleye · May 28, 2015 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.   Step:1 declare the following variables: An array named pints of the data type Real of size 7A variable named totalPints of the data type RealA variable named averagePints of the data type Real initialized to 0A variable named highPints of the data type Real initialized to 0A variable named lowPints of the data type Real initialized to 0above is the begining data______________________________________________________below is the python code i came up with i get errors and am not understanding what is happeningi am very new to this # Donald Goggleye# This lab will convert the blood drive program from LAB 9.1#Lab 9-4 Blood Drive#the main functiondef main():while endProgram == 'no':print# declare variablesDeclare Real SIZE = 7Declare Real pints[SIZE]Declare Real totalPints = 0Declare Real AveragePints = 0Declare Real highPints[0]Declare Real lowPints[0]Declare counter = 0Pints = [0] *7  # function calls# the getPints functionpints = getPints(pints)counter = 0while counter < 7:    pints[counter]=input ("Enter pints collected:")    counter = counter +1return pints#the getTotal functiontotalPints = getPints(pints, totalPints)counter = 0while counter < 7:    totalPints = (totalPints + pints[counter])    counter = counter +1return totalPints#the getAverage functionaveragePints = getAverage(totalPints, [SIZE])averagePints = (averagePints / 7)return averagePints#the getHigh functionhightPints = getHigh(pints, highPints)hightPints[0]counter = 1while counter < 7:    highPints = (highPints, pints[counter])        if pints[counter] >highPints            then highPints = pints[counter]        end ifreturn highPints#the getLow functionlowPints = getLow(pints, lowPints)lowPints[0]counter = 1while counter < 7:    lowPints = (lowPints, pints[counter])        if pints[counter] < lowPints            then lowPints = pints[counter]        end ifreturn lowPints#the displayInfo functionprint( " the average pints donated is", averagePints )print (" the highest number of pints donated", highPints)print ( " the lowest number of pints donated", 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): ')# calls mainmain()

## Replies

 Dol Lod · May 28, 2015 When you say error, are you referring to a logic error or syntax error?In Python, indentation is everything. However, posting on this site loses all indentation. If you want help, you would have to paste at ideone.com and then have people examine the code. Alternatively, while highly unlikely, try using code tags and see if it works. Halcyon Abraham Ramirez · May 30, 2015 Step:1 declare the following variables:An array named pints of the data type Real of size 7A variable named totalPints of the data type RealA variable named averagePints of the data type Real initialized to 0A variable named highPints of the data type Real initialized to 0A variable named lowPints of the data type Real initialized to 0 Halcyon Abraham Ramirez · May 30, 2015 ``class RedCross:    def __init__(self):        self.totalPints = 0        self.people = 0        self.averagePints = []        self.low_to_high = []        self.pints_given = 0    def addPints(self):        Done = input("Do you want to add pints of blood? ")        while Done != "N":                            pints_given = input("How Many Pints? ")                self.totalPints += pints_given            self.low_to_high.append(pints_given)            self.people += 1            Done = input("Do you want to add even more pints of blood? ")    def Total(self):        print("\nThe number of pints today is {}".format(self.totalPints))            def Average(self):        average = self.totalPints / self.people        print("\nthe average pint today is {}\n".format(average))    def highest_to_lowest(self):        self.low_to_high.sort()        print("the lowest to highest orders of blood donated is",", ".join( str(i) + " pints" for i in self.low_to_high))                                    def main(self):        self.addPints()        self.Total()        self.Average()        self.highest_to_lowest()a = RedCross()a.main()this is my solution to your problem just thought I'd take a shot at it            ``
• 1

## Python

129,779 followers