Compsci 101, Fall 2012, September 17

By entering your name/net-id below you indicate you are in class on September 17 to answer these questions and that you have answered them. Your name should not appear unless you are in class when answering these questions.
Name_________________   net-id _______   Name_________________   net-id _______


Name_________________   net-id _______   Name_________________   net-id _______

  1. What is the value of the variable total after the segment below executes?
        total = 0
        for x in range(10):
            total = total + x
    
        #value here
    

    1. 50

    2. 55

    3. 60

  2. What is the value of st after the code below executes?
        st = ""
        for x in "python":
           st = x + st
    
        #value here
    

    1. python

    2. nohtyp

    3. ptyohn

  3. What is the value of st after the code below executes?
        st = ""
        for x in "python":
           st = st + x*2
    
        #value here
    

    1. ppyytthhoonn

    2. pythonpython

    3. nnoohhttyypp

  4. What is the value of st after the code below executes?
        st = ""
        py = "python"
        for x in range(1,7):
           st = st + py[-x]
    
        #value here
    

    1. python

    2. nohtyp

    3. arrgh

  5. 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  
    
    
    1. "scuba"
    2. "eonrp"
    3. "fdrgs"