Lecture Week 1 Wed 10/2

Lecture Week 1 Wed 10/2#

Announce results for Guess 1/2 of the average

# create a list of all number in 
# [1,100] that are divisible by 7
# how many of them
x = [1,2,3]
len(x)
3
x.append(4)
x
[1, 2, 3, 4]
x = []
for i in range(1,101):
    if i % 7 == 0:
        x.append(i)
print(x)
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
len(x)
14
divisible_by_7 = [number for number in range(1, 101) if number % 7 == 0]
divisible_by_7
[7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]
x = [True, 1, 'hello']
# what is x[1]
x[0]
True
x[1]
1
x[2]
'hello'
x[-1]
'hello'
x = list(range(0,10))
x
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
x[1:9:2]
[1, 3, 5, 7]
a = [1,2,3]
b = a
b[1] = 100
a
# what is a
[1, 100, 3]
a.append(4)
b
[1, 100, 3, 4]
def fun(x):
    return x + 1
fun(3)
4
def fun_no_return(x):
    y = x + 1
print(fun_no_return(2))
None