Name: __________________
Student ID: __________________
  1. Describe the five program structure/flow
    abstractions mentioned in the text.

    ___________ ___________ ___________ ___________ ___________
  2. Describe the five hardware abstractions mentioned in the text.

    ___________ ___________ ___________ ___________ ___________
  3. Fill in the blank:
    1. "Computers are t________s, and computing scientists are t___________s."
    2. A procedure that invokes itself is called a _________________ procedure.
    3. In statically-typed languages, before we can use the value of a variable for the first time in
      a program, we need to ________________ and ___________________ it.
    4. True or False (circle one): The word define is a legal Python identifier.
    5. What English part of speech should a variable generally be? ___________
    6. Assume myFile is a file handle that has already been opened for reading. We wish to ensure that the next read() starts from the beginning of the file. What command do we use (including any arguments)? ______________________
    7. The standard function that converts strings to ALL-CAPS is found in the
      _______________ standard library and is named _______________ .
    8. The standard function that evaluates natural logarithms is found in the
      _______________ standard library and is named _______________ .
    9. The standard error I/O channel is found in the
      _______________ standard library and is named _______________ .
    10. A requirement imposed by a function upon its parameters, such that the correctness of the result is not guaranteed if the requirement is not met, is called a _______________________ .
    11. A RAM module contains 32 chips, each of size 256Mb. What is the total capacity of the RAM module, in bytes/kilobytes/megabytes/gigabytes (use binary units)? _________________ .
  4. Name two operations/functions/properties that Python lists have that M2/C arrays do not.
  5. Explain all the differences between the following, and give examples of each:
    1. reserved words:


    2. standard identifiers:


    3. standard library items:


  6. What is a backtrace?





  7. Assume that the positive integer with binary representation 1100101 is stored in variable x. Evaluate as Python:
    1. hex(x)
    2. oct(x)
  8. Use the Python range() function to create this list: [ 11, 8, 5, 2 ].


  9. Write Python code to create a 15x25 matrix, using lists.








  10. What is wrong with the following block of Python code? How would you fix it?
    apples = [ 'Fuji', 'Gala', 'Braeburn', 'Rome' ]
    idx = 1
    while idx <= len(apples):
    	print apples[idx],
    	idx += 1
    
  11. Evaluate each of the following Python expressions exactly as given, or if it produces an error, describe the error. Assume each expression is independent of the others. Assume all necessary imports have been done. For all expressions, assume the following initialization:
    	myApple = "Braeburn"	
    1. 2 + 3>4 and (5/0 < 1)
    2. 2.0 + 14 / 4
    3. "%03d%s" % (27.95, 'apples')
    4. "%05.2f" % 3.1415926
    5. len(myApple) = 7
    6. range(len(myApple))
    7. myApple[2:5]
    8. string.upper(myApple[-1])
    9. myApple < "Brayburn"
    10. 'z' < 'w'
    11. ord('z') - ord('w')
    12. 'z' - 'w'
    13. 'z' + 'w'
    14. 6 & 5



  12. What is output by the following block of Python code?
    def increment(x, y):
    	x += y
    a = 3
    b = range(3)
    increment(a, 1)
    increment(b, [1])
    print "a = ", a, "b = ", b
    
  13. What is output by the following block of Python code?
    myList = [ ('a', 'b'), range(5), [ [2, 3, 4], 5], 'xyz' ]
    for item in myList:
    	print len(item),
    




  14. Assume that myList is a Python list. Explain all the differences between
    yrList = myList and yrList = myList[:].






  15. Tell me everything you know about libraries in the context of programming.