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 and store the values in a list. 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: Start the IDLE Environment for Python. Prior to entering code, save your file by clicking on File and then Save. Select your location and save this file as LastName_Project9.py. Be sure to include the .py extension. Step 2: Document your program Include your name, the date, project name and a brief description of what the program does. \# Your Name \# Date \# Project Name \# Enter a summary of what the overall program does. Step 3: Code the main method: \# the main method def main(): endProgram = 'no' print() while endProgram == 'no':
Step 3: Code the main method: \# the main method def main(): endProgram = 'no' print() while endProgram == 'no' : print () # declare variables \# function calls 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):') \# the getPints function \# the getTotal function
\# the getpints function \# the getrotal function \# the getAverage function \# the getHigh function \# the getLow function \# the displayInfo method \# start the program main() Step 4: declaring variables In the corresponding section of the mair pints =[0]?7
Step 4: declaring variables In the corresponding section of the main method, declare your variables and initialize them to 0 . The array/list should be declared as follows: pints =[0]?7 Step 5: Write a function call to the getPints function This function must pass it the pints array (list). The function will return pints, so set it equal to the function call. This should be done as follows: pints = getPints ( pints ) Just remember, any statement read automatically reads anything in as a string; you will need to do a typecast after it reads the values to make sure it adds them in as a Int. Step 6: getPints function Write a while or a for in loop that will allow the user to enter pints into the array. Remember to use the pseudocode developed in section 2. Step 7: Write a function call to the getTotal function In this function call pass it pints and totalPints. This function should be set to the total Pints variable since it will be returned from the function. The call might look as follows: totalpints = getTotal (pints, totalPints) Step 8: Write the getTotal function, Add the following statements: - Initialize counter back to 0 - Add a while loop that runs 7 iterations and includes: - Accumulate totalPints by setting totalPints = totalPints + pints[counter] - Increment counter
Accumulate totalPints by setting totalPints = totalPints + pints [counter] - Increment counter - Return totalPints Step 9: Write a function call to the getAverage function Pass it totalPints and averagePints. This function should be set to the averagePints variable since it will be returned from the function. The call might look as follows: averagePints = getAverage (totalPints, averagePints) Step 10: Write the getAverage function Add the following statements: - A statement that will calculate averagePints as totalPints / 7 - Return averagePints Step 11: Write a function call to the getHigh function Pass it pints. This function should be set to the highPints variable since it will be returned from the function. The call might look as follows: highPints = getHigh (pints ) Step 12: Write the getHigh function Add the following statements: - Initialize highPints to pints[0] - Set counter to 1 - Write a while loop that runs 7 iterations and includes: An if statement that checks to see if pints[counter] > highPints
Add the following statements: - Initialize highPints to pints[0] - Set counter to 1 - Write a while loop that runs 7 iterations and includes: - An if statement that checks to see if pints[counter] > highPints - If it is true, set highPints to pints[counter] - Increment counter by 1 - Return highPints - Be careful to watch your indentation on this function. Step 13: Write a function call to the getLow function Pass it pints. This function should be set to the lowPints variable since it will be returned from the function. The call might look as follows: lowPints = getLow (pints) Step 14: Write the getLow function Add the following statements: - Initialize lowPints to pints[0] - Set counter to 1 - Write a while loop that runs 7 iterations and includes: - An if statement that checks to see if pints[counter] < lowPints - If it is true, set lowPints to pints[counter] - Increment counter by 1 - Return lowPints - Be careful to watch your indentation on this function. Step 15: Write a function call to the displaylnfo function Pass it averagePints, highPints, and lowPints.
Pass it averagePints, highPints, and lowPints. Step 16: Write the displaylnfo function Write the statements that will do the following: - Display the average pints donated - Display the highest number of pints donated - Display the lowest number of pints donated
Step 3: Code the main method: \# the main method def main(): endProgram = 'no' print() while endProgram == 'no' : print () # declare variables \# function calls 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):') \# the getPints function \# the getTotal function
\# the getpints function \# the getrotal function \# the getAverage function \# the getHigh function \# the getLow function \# the displayInfo method \# start the program main() Step 4: declaring variables In the corresponding section of the mair pints =[0]?7
Step 4: declaring variables In the corresponding section of the main method, declare your variables and initialize them to 0 . The array/list should be declared as follows: pints =[0]?7 Step 5: Write a function call to the getPints function This function must pass it the pints array (list). The function will return pints, so set it equal to the function call. This should be done as follows: pints = getPints ( pints ) Just remember, any statement read automatically reads anything in as a string; you will need to do a typecast after it reads the values to make sure it adds them in as a Int. Step 6: getPints function Write a while or a for in loop that will allow the user to enter pints into the array. Remember to use the pseudocode developed in section 2. Step 7: Write a function call to the getTotal function In this function call pass it pints and totalPints. This function should be set to the total Pints variable since it will be returned from the function. The call might look as follows: totalpints = getTotal (pints, totalPints) Step 8: Write the getTotal function, Add the following statements: - Initialize counter back to 0 - Add a while loop that runs 7 iterations and includes: - Accumulate totalPints by setting totalPints = totalPints + pints[counter] - Increment counter