loops and lists amounts [for in range( + ) *( + / )** amounts append(aprint(amountsstart with empty list add new element to amounts list the parts worth noting in this code are amounts []which simply creates list with no elementsand the use of the append function inside the for loop to add elements to the list this simple way of creating list and filling it with values is very common in python programs mathematical sums are implemented as for loops very common example of repetitive task in mathematics is the computation of sumfor instancen si = for large values of such sums are tedious to calculate by handbut they are very easy to program using range and for loopn for in range( + ) + ** notice the structure of this codewhich is quite similar to the way we filled list with values in the previous example firstwe initialize the summation variable (sto zeroand then the terms of the sum are added one by one for each iteration of the for loop the example shown here illustrates the standard recipe for implementing mathematical sumswhich are common in scientific programming and appear frequently in this book it is worthwhile spending some time to fully understand and remember how such sums is implemented how can we change the elements in listin some cases we want to change elements in list consider first simple example where we have list of numbersand want to add the value of two to all the numbers following the ideas introduced abovea natural approach is to use for loop to traverse the listas followsv [- for in ve print( [- unaltered!