codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
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()
Private
[
?
]
Run code
Submit