Lab 4

 For this lab i typed a function that takes a string as an argument and displays the letters “backward” one per line for exercise 1 ch.8 and for exercise 3 ch.10 i wrote a function that takes a list of numbers and returns the cumulative sum. my experience with this lab was easy going not too hard.

def backward(x):                                                                                                               index=-1                                                                                                                   length=(-1*len(x))                                                                                                          while index >= length:                                                                                                          letter = x[index]                                                                                                                 print (letter)                                                                                                                          index = index -1 print (backward(“mp123456789”))

 

 

Exercise #3 chapter 10

def accum(x):                                                                                                             y=x                                                                                                                                      index=1                                                                                                                                post=0                                                                                                                                      y[0]=x[0]                                                                                                                                           y[index]=x[post]+x[index]

while post<index:                                                                                           index=index+1                                                                                                  post=post+1                                                                                                                        if index==len(x):                                                                                                                    print (y)                                                                                                                     break                                                                                                                                     y[index]=y[post]+x[index]

t=[1,2,3,4,5,6,7,8,9]                                                                                                            accum(t)