Compsci 101, Fall 2012, Lab 2

By entering your name/net-id below you indicate you are present for Lab 2 to answer these questions and that you were part of the process that resulted in answers being turned in.

Name: ______________    Net id: _____________ || Name: ______________    Net id: _____________

Name: ______________    Net id: _____________ || Name: ______________    Net id: _____________

  1. String Slicing and Dicing

    Provide your answers to 3-7, creating each word by slicing:
  2. 
    
    

  3. 
    
    

  4. 
    
    

  5. 
    
    

  6. 
    
    
  7. 
    
    

  8. 
    
    

Create your own slicing/word puzzle: what's the word and what's the answer?





Vocabulary

  1. What do you think the name of the string method is that returns the lower case version of a string?
    
    
    
    
    
  2. The function max returns the maximal value of a string as well as a list. What is max("science") and why?
    
    
    
    
    
    
    
  3. What is the value of reversed(sorted([5,4,1,2,8])) and why?
    
    
    
    
  4. What is the value of sorted(lst).index(min(lst)) for any list lst? Why? What's the value if min is replaced by max?
    
    
    
    
    
  5. Why is the value of str.endswith(str[-3:]) True?
    
    
    
    
  6. When is the value of st.upper().endswith(st) True? (Provide a specific example of when it's true and try to generalize)
    
    
    
    
    
  7. The in operator determines if its left operand occurs in its right operand and returns a boolean value. This means 'a' in 'stranger' evaluates to True. What is the value of 5 in [1,2,3,4]?
    
    
    
    
  8. Explain when the value of st[0:2] in st is False? (Provide a specific example of when it's true and try to generalize)
    
    
    
    
    
  9. Explain when the value of st[0:2]*2 in st is True? (Provide a specific example of when it's true and try to generalize)
    
    
    
    
    
  10. When is the value of lst.count(lst[0]) the same as the value of len(lst) for a list lst? (Provide a specific example of when it's true and try to generalize)
    
    
    
    
    
    
    


APT Acronym

Write a brief, English description of how to solve the APT.













  1. Complete the code statement below.
      words = 
    
    
  2. Write the for-loop here:
    
    
    
    
  3. Write loop to create the acronym:
      acro = ""
    
    
    
    
    
    
    
      return acro