Compsci 101, Fall 2012, September 5

By entering your name/net-id below you indicate you are in class on September 5 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. In Python, which of the following is an expression for how many meters an object falls due to gravity on Earth when the initial velocity is velo (m/sec) and the object falls for sec seconds. More than one may be correct.

    1. velo*sec + 4.9*sec*sec

    2. 9.8*(sec**2)/2 + sec*velo

    3. Math.gravity(velo,sec)

  2. What is the value of the Python expression below?
        "ba"*3 + "na"*2
    

    1. error

    2. bababanana

    3. bananabananabanana

    4. bananabanana

  3. WHatis the value of the Python expression below?
       "ba" + 3 * "na" + 2
    

    1. error

    2. bababanana

    3. bananabananabanana

    4. bananabanana

  4. What is the value of the Python 2.7 expression
        16 / 7 + 16 % 3
    

    1. 2

    2. 3

    3. 4

    4. other

  5. In Python what is printed when the loop below executes:
      for s in "duke":
         print s*3,
    
    

    1. ddduuukkkeee

    2. dukedukeduke

    3. error

  6. Which best characterizes the function days below: def days(month): if month == "January": return 31 elif month == "March": return 31 elif month == "May": return 31 elif month == "July": return 31 elif month == "August": return 31 elif month == "October": return 31 elif month == "December": return 31 elif month == "February": return 28 else: return 30
    1. It correctly returns the number of days in a month represented by parameter month, but it's wrong for February in a leap year.

    2. Each of the elif occurrences could be replaced by if and the code word work the same way

    3. The function returns 30 for the call days("january")