Lab 4

Assignment – Lab 4

1. Write a function that takes a string as an argument and displays the letters backward, one per line.

Description-  Define a list of letter and set it as a value of something.Using a while loop I made the letters display on each line.To make the starting letter be the last, i put the value of index as -1 and subtracted 1 from index after each loop.

 

 

2. 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].

Lab4

 

Leave a Reply

Your email address will not be published. Required fields are marked *