Inspect state after raising

A booking program uses the following Python code. The list audit records attempted sales, including rejected attempts.


Python
stock = 35
audit = []

def sell(quantity):
    audit.append(quantity)
    if quantity > stock:
        raise ValueError("not enough seats")
    return stock - quantity

stock = sell(41)


An external test harness runs the module's top-level code, catches the exception raised by the last line, and then inspects the variables without changing them. Find the stored value of stock, in seats, and the number of entries in audit. Enter both answers as exact integers.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Raising Exceptions Questions: