A booking program uses the following Python code. The list audit records attempted sales, including rejected attempts.
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.
Unlock full course notes by signing up
Follow a failure through a caller
A theatre calculates remaining seats with the following Python functions. All quantities are integer seat counts, and neither function handles exceptions.
What happens when reserve_two(12) is evaluated?
Prioritize overlapping rejections
A warehouse reserves items in complete cartons of six. The following Python function receives integer quantities measured in individual items; stock is nonnegative.
Give both requested answers:
The exact exception message from reserve(25, 20), without quotation marks.
Preserve the rejection rule
A workshop permits integer group sizes from 1 through 16. Its Python validator is:
Select every change that preserves exactly which integer inputs cause an exception to be raised. Compare exception occurrence only; the exception messages need not match.
Evaluate the object supplied to raise
A Python inventory checker calls reject_order to signal a rejected request. Its helper either constructs a shortage exception or raises an exception about invalid stock data. All quantities are integer item counts.
For each independent call, enter the exact exception message without quotation marks. Also enter the name of the function that directly raises the reported exception: make_problem or reject_order. Constructing or returning an exception object does not count as raising it.