Console from Sept 27, 2011 CompSci 6 strand = 'cgcgcgaaattt' length = len(strand) xx = [1 for ch in strand] yy = [ch+ch for ch in strand] zz = [3 for silly in strand] print xx [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] print sum(xx) 12 print yy ['cc', 'gg', 'cc', 'gg', 'cc', 'gg', 'aa', 'aa', 'aa', 'tt', 'tt', 'tt'] print zz [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3] [silly+silly for silly in strand] ['cc', 'gg', 'cc', 'gg', 'cc', 'gg', 'aa', 'aa', 'aa', 'tt', 'tt', 'tt'] print sum([1 for ch in strand if ch == 'g' or ch == 'c']) 6 print strand cgcgcgaaattt print [nutsy*5 for nutsy in strand] ['ccccc', 'ggggg', 'ccccc', 'ggggg', 'ccccc', 'ggggg', 'aaaaa', 'aaaaa', 'aaaaa', 'ttttt', 'ttttt', 'ttttt'] words = ['zebra', 'bear', 'cow', 'dog'] print length # note this is the length from way above, length = len(strand) 12 len(words) 4 [w for w in words if len(w)== 3] ['cow', 'dog'] [len(w) for w in words if len(w)== 3] [3, 3] ['x' for w in words if len(w)== 3] ['x', 'x'] [w+"ay" for w in words if len(w)== 3] ['coway', 'dogay']