#lists
xs = [10,20,30,40]
print(xs)
[10, 20, 30, 40]
#tuples
ys = ("A",430)
counts = [("A",430),("B",230)]
len(xs)
4
xs[2]
30
xs[1:3]
[20, 30]
xs.append(60)
xs
[10, 20, 30, 40, 60]
for x in xs:
print(x)
10 20 30 40 60
sum = 0
for x in xs:
sum = sum + x
print(sum)
160
# conditional statement; sum the odd numbers in a list
zs = [1,2,3,4,5,6,7,8,9,10]
sum = 0
for z in zs:
if z%2 == 1:
sum = sum + z
print(sum)
25
def sum_odd(zs):
sum = 0
for z in zs:
if z%2 == 1:
sum = sum + z
return sum
answer = sum_odd([1,2,3,4,5,6,7,8,9,10])
print(answer)
25
answer = sum_odd([36,91,100,41])
print(answer)
132