Assume that you have stored a list of numbers in a variable called aList. You should NOT initialize this list,
Assume that you have stored a list of numbers in a variable called aList. You should NOT initialize this list, just use the variable name in your code and assume it holds a list of numbers.
You do not know how many numbers are in aList, and your program should work for anylength list. Remember, you know how to find the length of any list using a python function.
Hint, you will need to find the length of aList! Problem: Given a list of numbers (described above) use a while loop to compute the sum of the number in the list and store it in a variable called total. Values will be added one at a time inside the loop to total until all values in the list have been added in. You will access the list values using their INDEXES. That means you need a variable to hold the current index. Call that variable index.Do not use built-in functions like sum, you must add one value at a time to total in the loop.
NO use of break or continue allowed, you must properly structure your loop with the loop variable initialization before the loop starts, test of the loop variable in the loop statement, update of the loop variable in the loop, generally (and in this case) the update will be the last statement in the loop. After the loop is over, print the value of total. Below are specific questions about this problem. There are 6 questions, then there is
writing the code. Point values given below.
(a) Write expression in python that will give you the length of the variable aList:
(b) To think about the problem it can be helpful to use an actual example and to write notes, see how that would work. Here is an example list: [2, 6, 1, 4] Write the INDEXES for this list under the values: ---------
(c) Assume the list in part (b) is stored in the variable aList, write an expression that uses the correct index to refer to the value 6 in aList.
(d) List all the variables you think you will need for this problem. Write their name, then a short description of what they hold, and how they get their initial value. For aList you can just write "given" for the initial value
(e) What variable is the loop variable in this problem? Note, the loop variable is the one whose value determines when the loop will stop:
(f) What condition will cause the loop to stop and why?