Compsci 6, Fall 2011, Classwork 7

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

Name: __________________________   NetID: _____________

Name: __________________________   NetID: _____________

Problem:

  1. A five letter word is printed by the code below, what is it?
      words = ["self", "contained", "underwater", "breathing", "apparatus"]
      abb = ""
      for w in words:
          abb = abb + w[1]
      print abb  
    
    
    
    
    
    
    
    
  2. The code below prints 4, modify it in a good way to print 4.5 which is arguably a "better" value.
        nums = [4,5,4,5,4,5,4,5]
        total = sum(nums)
        print total/len(nums)
    
    
    
    
    
    
    
    
  3. What does this function do?
    def changeup(s):
        answer = ""
        for ch in s:
            answer = answer + ch*2
        return answer
    
    
    
    
    
    
    
    
  4. Complete the function below.
    def is_vowel(ch):
        '''
        returns True if ch is a vowel (a, e, i, o or u)
        else returns False
        '''
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  5. Complete the function below. (WE DIDN"T GET TO THIS ONE)
    def allvowels(word):
        """
        returns true if the word is all vowels
        returns false otherwise
        """