Compsci 6, Fall 2011, Classwork 9

PRINT Names and NetID of students in group (min 2, max 3)
Name: __________________________   NetID: _____________

Name: __________________________   NetID: _____________

Name: __________________________   NetID: _____________

Problems:

  1. Consider the following code. What is output?
    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 
    print sum(xx)
    print yy
    print zz
    print sum([1 for ch in strand if ch =='g' or  ch == 'c'])
    
    output:
     
    
    
    
    
    
    
    
  2. Complete the function
    def joinTogether(mylist, separator):
        # TODO: convert the list mylist into a string of items from 
        #        mylist separated by separator
    
    
    
    
    
    
    
    
    
    
    
        
        
        
        
        
        return "replace me"
    
  3. Complete the function
    def processLine(line):
        words = line.split()   # put the words into a list
        # TODO: Given a string of words, create a new string from those
        # words keeping only the words whose length is greater than 4
        
    
    
    
    
    
    
    
    
    
    
        
        return "replace me"