Description: Write a function that takes a string as an argument and displays the letters backward, one per line and write a function that takes a list of numbers and returns the cumulative sum; that is, a new list where the ith element is the sum of the first i+1 elements from the original list. For example, the cumulative sum of [1, 2, 3] is [1, 3, 6].
Work:
#Al Rivera #Date : 3/20/13 #Session: 9310 #Lab 4: String and Lists
print(‘————String————-‘) #ask user to input name and print reverse of it
index = -1 name = raw_input(‘Enter a name:’)
while index >= -len(name): letter = name [index] print letter index = index – 1 print(‘————-List—————‘)
def cumil_sum(list): x = 0 total = 0 while x < len(list): total += list[x] print total x = x + 1 return total list = [1,2,3] print cumil_sum(list)
Screen Shot: