Lab 4

For lab 4, we had to write a code that can write any  persons name backwards. The next part of the lab was to write a list that would find the sum of all the numbers given.

Code:

#Mabel Fermin
#Date 3/12/13
#Section: 9310
#Lab 4 String and Len

name = input (‘enter a name:’)
len_name = len(name)
name_rev = name[len_name -1]
print (name_rev)
len_name = len_name -1

while len_name != 0:
name_rev = name [len_name -1]
print (name_rev)
len_name = len_name -1

#List

def add_all(t):
total = 0
for x in t:
total = total + x
return total

t = [1, 2, 4, 8, 16]
sum (t)

Screenshot: