Lab 4

Description : Lab report 4 contains 2 exercises

Code:

def WordBackwards(word):
    index = len(word) - 1
    while index >=0:
        letter = word[index]
        print (letter)
        index = index - 1

Phrase = input("Please input a phrase ")
WordBackwards(Phrase)

Screenshot
lab 4

Code

def CumulativeSum():
    list = ['5', '8', '11', '85']
    index = 1
    while index < int(len(list)):
        x = int(list[index])
        y = int(list[index - 1])
        z = x + y
        list[index] = z
        index = index + 1
    print (list)

CumulativeSum()

Screenshot:
lab 4 part 2

Leave a Reply

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