Outline for April 24, 2014

Reading: none
Due: May 2, 2014
  1. Finishing up calculating π using a Monte Carlo method
    1. Fifth step: plot the points [mc5.py]
    2. Sixth step: add the results to the plot [mc6.py]
  2. How the for loop actually works
    1. For variable loops through the list
    2. Iterator: every time it is called, generates next item in the list
  3. Scope: global, local, parameters [scope.py]
  4. Handling exceptions
    1. except [except0.py]
    2. except error [except1.py]
    3. else [except2.py]
    4. except error as msgvar [except3.py]
    5. finally [except4.py]
    6. Exceptions in a function: who handles them? [except5.py, except6.py]
    7. Using global variables as error flags [except6a.py]
    8. raise [except7.py]
  5. Common exceptions
    1. ZeroDivisionError — attempt to divide (or take the remainder of) something by 0
    2. TypeError — operation or function applied to operand of wrong type
    3. SyntaxError — Python parser encountered a malformed statement
    4. NameError — local or global name is not found
    5. ValueError — built-in function or operation applied to operator with illegal value
    6. EOFError — input function encounters an end of file
    7. Keyboard Interrupt — user hit the interrupt key (usually control-C)

You can also obtain a PDF version of this. Version of April 23, 2014 at 10:07PM