Nov-15-2017, 12:09 AM
Basically. You have 7 iterations you must enter for pints of blood, or blood donations. Then, it calculates the total, average, and the high and low amount of blood donations. This type of thing could possibly be useful for when you are doing blood donations. The only thing is, the pints_collected is only taking into account the last digit the user inputs. I feel I am missing something simple but I just can't find it.
Any help is appreciated and I attached my code below.
Any help is appreciated and I attached my code below.
def pints_collected(): counter = 0 pints = 0 while counter < 7: counter = counter + 1 pints = int(input("Enter pints collected: ")) return pints def calculate_total(pints): '''The getTotal(pints, pintsTotal) function:''' pints_total = 0 pints_total = pints return pints_total def calculate_average(pints_total): pints_avg = pints_total / 7 return pints_avg def dispInfo(pints_total, pints_avg): print("The total number of pints donated was: ", pints_total) print("The average # of pints donated was %.2f " % pints_avg) # display float with 2 decimal return pints_total, pints_avg def main(): pints = pints_collected() pints_total = calculate_total(pints) pints_avg = calculate_average(pints_total) pints_total, pints_avg = dispInfo(pints_total, pints_avg) main()