IT 116: Introduction to Scripting
Answers to Class 21 Ungraded Quiz

  1. What Python statements should you put inside the try block of a try/except statement.
    any statement that can cause a runtime error
  2. What Python statements should you put inside the except block of a try/except statement.
    statements that deal with the runtime error
  3. When the Python interpreter comes across a runtime error inside the try bloc of a try/except statement, what does the interpreter do?
    the interpreter stops executing the code inside the try block
    and executes the code in the corresponding except block
  4. Can the statements inside a try block raise more than one kind of exception?
    yes
  5. If the code inside the try block can create more than one type of runtime error, what must you do if you want to do different things for each possible runtime error?
    create an except block for each possible exception type
  6. What happens whenever the Python interpreter runs some code that causes a runtime error?
    it creates an exception object
  7. If you had an except block that began
    except ValueError val_err:
    how would you print the error message contained in the exception object?
    print(val_err)
  8. When is the code in the else block of a try/except statement executed?
    after all the statements in the try block have run
    without raising an exception
  9. When is the code in the finally block of a try/except statement executed?
    after all the statements in the try block and
    all exception handlers have run
    			
  10. What do you call the statements inside an except block?
    the exception handler