Date & Time

Monday, March 29, 2:00-3:15pm, Online (Blackboard)

Overview

Test 2 will cover all material from the beginning of the semester through multiprocessing but with an emphasis on material covered since Test 1 (including files). This material includes everything discussed in lectures and covered in assignments, and aligns with chapters 1-10 from the recommended text. We have covered some additional topics the text has not, and we did not cover the data science additions to each chapter. Because this is a programming principles course, there will be questions related to principles as well as questions that involve syntax. You may be asked to write, analyze, and/or debug code.

Format

  • Multiple Choice
  • Free Response

Example Types of Questions

  • Which statement is a context manager associated with? Why is it useful when writing to files?
  • Why is it important to know which encoding a text file used?
  • Why would you use the statement if __name__ == "__main__" in a script?
  • What is the type of the entries in sys.argv? Suppose you are writing a script that takes two arguments and computes their sum; what may do you need to do before adding the arguments?
  • What is a wildcard import in Python? Why should you avoid them in general?
  • What is the difference between a Python module and a Python package?
  • What are the differences between a numpy array, a tuple, and a list?
  • Write a statement to refer to a specified subarray.
  • Create an inheritance hierarchy from the following classes: Vehicle, Car, Truck, SportsCar, Sedan
  • Given a definition of the Vehicle class, write a constructor for the Car class that takes the number of doors as an argument and stores it.
  • Given a definition of a class, locate errors and detail fixes for them.
  • Given an instance obj which has initialized instance fields var1, _var2, and __var3, which reference does not work? obj.var, obj._var2, obj.__var3?
  • What is the difference between a class method and a static method?
  • What is duck typing?
  • When handling an exception, why is using a bare except clause problematic?
  • What are some problems with debugging using print statements or testing using assert statements?