Lab 4

Description

In this lab, we showed how to use strings and lists. We had to first show a function that made a string spell itself backwards each letter on one line. Then after we make a function to make a list if the cumulative sum of the numbers provided.

Code

# Alex Charles
# 3/20/13
# Session 9306
# Lab 4A – Strings

index = 7
school = ‘CityTech’
while index < len(school):
letter = school[index]
print letter
index = index – 1

 

# Alex Charles
# 3/20/13
# Session 9306
# Lab 4B – Lists

numbers = [1, 2, 3]
def cumulative(numbers):
addition = []
total = 0
for i in numbers:
total += i
addition.append(total)
print addition

cumulative(numbers)

Screenshot