loop structures and booleans suppose we want to write program that can compute the average of series of numbers entered by the user to make the program generalit should work for any size set of numbers you know that an average is calculated by summing up the numbers and dividing by the count of how many numbers there are we don' need to keep track of all the numbers that have been enteredwe just need running sum so that we can calculate the average at the end this problem description should start some bells ringing in your head it suggests the use of some design patterns you have seen before we are dealing with series of numbers--that will be handled by some form of loop if there are numbersthe loop should execute timeswe can use the counted loop pattern we also need running sumthat calls for loop accumulator putting the two ideas togetherwe can generate design for this problem input the count of the numbersn initialize sum to loop times input numberx add to sum output average as sum hopefullyyou see both the counted loop and accumulator patterns integrated into this design we can translate this design almost directly into python implementation average py def main() eval(input("how many numbers do you have")sum for in range( ) eval(input("enter number >")sum sum print("\nthe average of the numbers is"sum nmain(the running sum starts at and each number is added in turn after the loopthe sum is divided by to compute the average here is the program in action how many numbers do you have enter number > enter number > enter number > enter number > enter number > the average of the numbers is