>>> strand = "cgcgcgaaattt" >>> len(strand) 12 >>> [1 for ch in strand] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] >>> xx = [1 for ch in strand] >>> xx [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] >>> len(xx) 12 >>> sum(xx) 12 >>> yy = [0 for ch in strand] >>> yy [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] >>> yy = [ch+ch for ch in strand ... ] >>> yy ['cc', 'gg', 'cc', 'gg', 'cc', 'gg', 'aa', 'aa', 'aa', 'tt', 'tt', 'tt'] >>> strand 'cgcgcgaaattt' >>> [3 for nutsy in strand] [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] >>> [nutsy*5 for nutsy in strand] ['ccccc', 'ggggg', 'ccccc', 'ggggg', 'ccccc', 'ggggg', 'aaaaa', 'aaaaa', 'aaaaa', 'ttttt', 'ttttt', 'ttttt'] >>> strand 'cgcgcgaaattt' >>> [1 for ch in strand if ch == 'g' or ch = 'c'] File "", line 1 [1 for ch in strand if ch == 'g' or ch = 'c'] ^ SyntaxError: invalid syntax >>> [1 for ch in strand if ch == 'g' or ch == 'c'] [1, 1, 1, 1, 1, 1] >>> cgs = [1 for ch in strand if ch == 'g' or ch == 'c'] >>> cgs [1, 1, 1, 1, 1, 1] >>> len(cgs) 6 >>> sum(cgs) 6 >>> strand 'cgcgcgaaattt' >>> words = ["zebra", "bear", "cow", "dog"] >>> words ['zebra', 'bear', 'cow', 'dog'] >>> len(words) 4 >>> [w for w in words if len(w) > 4] ['zebra'] >>> [len(w) for w in words if len(w) == 3] [3, 3] >>> [w for w in words if len(w) == 3] ['cow', 'dog'] >>> [x for w in words if len(w) == 3] Traceback (most recent call last): File "", line 1, in NameError: name 'x' is not defined >>> [x for x in words if len(x) == 3] ['cow', 'dog'] >>> ['x' for w in words if len(w) == 3] ['x', 'x'] >>> x = 7 >>> [x for w in words if len(w) == 3] [7, 7] >>> zoo =['zebra', 'antelope', 'bear', 'orangutan', 'unicorn', 'chimp', 'goldfish'] >>> zoo ['zebra', 'antelope', 'bear', 'orangutan', 'unicorn', 'chimp', 'goldfish'] >>> len(zoo) 7 >>> [len(w) for w in zoo] [5, 8, 4, 9, 7, 5, 8] >>> max([len(w) for w in zoo]) 9 >>> zoo[9] Traceback (most recent call last): File "", line 1, in IndexError: list index out of range >>> max([len(w) for w in zoo]) 9 >>> [len(w) for w in zoo].index(9) 3 >>> zoo[3] 'orangutan' >>> max(zoo) 'zebra' >>> zoo ['zebra', 'antelope', 'bear', 'orangutan', 'unicorn', 'chimp', 'goldfish'] >>> min(zoo) 'antelope' >>> zoo.append("aardvark") >>> zoo ['zebra', 'antelope', 'bear', 'orangutan', 'unicorn', 'chimp', 'goldfish', 'aardvark'] >>> min(zoo) 'aardvark' >>>