Outline for March 5, 2018

Homework: due March 6, 2018 at 11:59pm


  1. Fun problem: number of grains of rice on the chessboard [rice_chess.py]
  2. Character/integer conversions [chr.py][ord.py]
    1. Cæsar cipher (shift cipher) [caesarenc.py][caesardec.py]
  3. 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)
  4. Handling exceptions
    1. except [except0.py]
    2. except exceptcode [except1.py]
    3. else [except2.py]
    4. except exceptcode 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 exceptcode message [except7.py]
  5. Online Python documentation
  6. JSON [json-ex.py]
    1. What it is
    2. json.loads
    3. json.dumps

Matt Bishop
Department of Computer Science
University of California at Davis
Davis, CA 95616-8562 USA
Last modified: Version of March 5, 2018 at 7:20PM
Winter Quarter 2018
You can get a PDF version of this