[ create a new paste ] login | about

Link: http://codepad.org/4t1dfXYj    [ raw code | output | fork | 2 comments ]

Python, pasted on Oct 29:
def main():
    totalPints = 0
    averagePints = 0
    highPints = 0
    lowPints = 0
    counter = 0
    pints = [0] * 7
    pints = getPints(pints)
    totalPints = getTotal(pints)
    averagePints = getAverage(totalPints)
    highPints = getHigh(pints)
    lowPints = getLow(pints)
    displayInfo = displayInfo(averagePints, highPints, lowPints)

    endProgram = 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 = input('Do you want to end program? (Enter no or yes): ')

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

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

def getAverage(totalPints):
    averagePints = float(totalPints) / 7
    return averagePints

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

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

def displayInfo(averagePints, highPints, lowPints):
    print("The Average collected is: ", averagePints)
    print("The High Volume collected is: ", highPints)
    print("The Low Volume collected is: ", lowPints)

main()


Output:
1
2
3
4
5
6
7
8
Enter pints collected: Traceback (most recent call last):
  Line 63, in <module>
    main()
  Line 8, in main
    pints = getPints(pints)
  Line 23, in getPints
    numEntered = input('Enter pints collected: ')
EOFError


Create a new paste based on this one


Comments:
posted by Carter895 on Oct 29
Can someone assist me with getting this to work properly? It's supposed to gather values, average them, then list the average, high number, and low number, but for some reason I can't get it past inputting the initial values.
reply
posted by Carter895 on Oct 29
Forgot to mention, using python 3.2.2 if that helps.
reply