IT 116: Introduction to Scripting
Quiz 9 Answers

  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. Can the statements inside a try block raise more than one kind of exception?
    yes
  3. 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
  4. 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
    			
  5. What do you call a collection of things stored one right after another?
    a sequence
  6. What is a list?
    a sequence object that can be changed
  7. What is a tuple?
    a sequence object that cannot be changed
  8. Write an assignment statement that creates an empty list and assigns it to the variable empty.
    empty = []
  9. Write an assignment statement that creates a list of the first 5 integers and assigns it to the variable l1.
    l1 = [1, 2, 3, 4, 5]
  10. What expression would you write to get the number of values in the list l1?
    len(l1)