
n = 100

def f(x):
    n = x
    print "smash"

f("mmmm")

x = [10]

def g(z):
    z[0] = "abc"

g(x)




# Generators

prices = { "GOOG" : 490.10
         , "AAPL" : 145.23
         , "YHOO" : 21.71 }

for key in prices:
    print key


for s in "Cranberry Sawce":
    print s

for line in "lec-generators.py":
    print line


items = [1, 3, 5]
it    = iter(items)

it.next()
it.next()
it.next()
it.next()


class countdown(object):
    def __init__(this, start):
        this.count = start
    def __iter__(this):
        return this
    def __next__(this):
        if this.count <= 0:
            raise StopIteration
        this.count -= 1
        return this.count




for i in countdown(10):
    print i,



def countdown(n):
    while n > 0:
        yield n
        n -= 1


for i in powersOfTwo(2000):
    print i





def powersOfTwo(n):
    p = 1
    while (p < n):
        yield p
        p = 2 * p




def bits(n):
    if n <= 0:
        return [[]]
    else:
        return [[b] + r for b in [0,1] 
                        for r in bits(n-1)]

a = [1,2,3,4]

b = (2*x for x in a)

c = (2*y for y in b)



e for x1 in s1 if c1
  for x2 in s2 if c2
  for x3 in s3 if c3


for x1 in s1:
    if c1:
        for x2 in s2:
            if c2:
                for x3 in s3:
                    if c3:
                        yield e


t = ((x,y) for x in range(5) for y in range(5) if x < y)







def sum(x):
    res = 0
    for i in x:
        res += i
    return res


def addLogs(file):
    f = open(file)
    tot = 0
    for line in f:
        bytestr = line.rsplit(yak)
        if bytestr != "-":
            tot += int(bytestr)
    return tot

def addDiskLogs(path):
    tot = 0
    for f in filesInPath(path):
        tot += addLogs(f)
    return tot
























def boo(a):
    for x in a:
        yield 2*x














def powersOfTwo(n):
    p   = 1
    res = []
    while (p < n):
        res.append(p)
        p = 2 * p
    return res








