In this article

Give an AI-assisted interview rehearsal checkpoints that end with evidence: a clear contract, a failing case, a runnable repair, and verified behavior. This illustrative 45-minute plan repairs a Python inventory helper while preserving time to test and explain the change. Use AI only when the assessment explicitly permits it.

Choose checkpoints you can recognize while working

A timer helps only if you know what should exist when it rings. For this rehearsal, the first useful result is a reproducible failure; the final result is a small repair whose evidence you can explain. The schedule below is a proposed practice structure, not a claim about any employer's interview length or scoring. Adapt it to the invitation, permitted tools, task size, and interviewer guidance.

Use the stock-reservation exercise throughout rather than changing tasks halfway through. Start with a dictionary of product counts and a helper that reserves a quantity. Assume the environment already runs Python. If installation or access consumes the opening minutes, make that delay visible and revise the plan. A schedule cannot recover time by pretending setup was free.

  • Minutes 0–6: run the starting code and locate the state change.

  • Minutes 6–12: agree on the contract and reproduce a failed reservation.

  • Minutes 12–25: produce one focused, runnable repair.

  • Minutes 25–35: verify success, rejection, boundaries, and unchanged input.

  • Minutes 35–41: review the diff and address one remaining concern.

  • Minutes 41–45: explain the evidence, limits, and next step.

Minutes 0–6: find the write before asking for a rewrite

The original helper subtracts the quantity before checking availability. With three units of tea, asking for four raises an error but leaves negative stock behind. The exception looks appropriate if you inspect only the return path. Read the caller's data after the error as well. Write down that observation before asking the assistant to explain it; this keeps the conversation attached to something you have reproduced.

Ask a bounded question: Which line changes the caller's inventory, and what state remains after requesting four units from three? The useful answer names the subtraction and the value minus one. Avoid spending this stage comparing frameworks, redesigning storage, or requesting a complete service. The immediate uncertainty concerns one helper and its state ownership.

Original helper: rejection happens after the inventory changes
Codepython
def reserve_broken(stock, sku, quantity):
    stock[sku] -= quantity
    if stock[sku] < 0:
        raise ValueError("insufficient stock")
    return stock

    Minutes 6–12: turn the failure into an explicit contract

    For this exercise, stock is an already valid dictionary from product names to nonnegative integer counts. Quantity must be an ordinary positive integer; booleans, floats, text, and null are rejected. An unknown product raises KeyError, and insufficient stock raises ValueError. A successful call returns a separate updated dictionary. The original dictionary must remain unchanged on both success and failure. These are practice requirements, not universal inventory rules.

    Trace two literal outcomes: reserving two from three returns one, while reserving four raises and leaves three. Then resolve the boundary: reserving exactly three is allowed and returns zero. Confirm the exception categories before accepting a patch that silently clamps quantities. Python booleans are integer subclasses, so an ordinary integer requirement needs to distinguish them deliberately. Python: dictionaries and Boolean types

      Minutes 12–25: finish one repair you can execute

      Ask the assistant to preserve the agreed input and error behavior, move rejection checks ahead of the write, and keep the change inside the helper. Inspect the proposed order yourself. The corrected version below validates quantity, confirms the product, checks availability, and only then creates the updated result. If several inputs are invalid, this order also defines which error appears first; do not claim that unspecified combinations were exhaustively checked.

      The implementation copies the dictionary before replacing a count. Python documents dict.copy as a shallow copy. That is sufficient for this exercise's integer counts, but it would not isolate mutations inside nested product objects. Python: dictionaries and Boolean types At minute 25, the checkpoint is a callable function with an observed result. If you are still choosing abstractions, reduce scope and return to the failure you can demonstrate.

      Focused repair with validation before the returned state change
      Codepython
      def reserve(stock, sku, quantity):
          if type(quantity) is not int:
              raise TypeError("quantity must be an integer")
          if quantity <= 0:
              raise ValueError("quantity must be positive")
          if sku not in stock:
              raise KeyError(sku)
          if quantity > stock[sku]:
              raise ValueError("insufficient stock")
          updated = stock.copy()
          updated[sku] -= quantity
          return updated

        Minutes 25–35: protect the time for independent checks

        Put the repaired helper and the tests below in reservation_test.py, then run python reservation_test.py -v. The suite uses fixed expected inventories rather than calculating expectations by copying the helper's subtraction. It checks exact availability, invalid types, absent products, and stock after rejection. Eight test methods passed on Python 3.14.4 when preparing this article. Subtests distinguish multiple invalid inputs within a method. Python: unittest assertions and subtests

        Challenge one attractive shortcut: change updated = stock.copy() to updated = stock. Two methods then fail, covering successful-call isolation and successive returned states. That mutation shows why checking only the remaining count is weak. In the original broken helper, the rejected four-unit request leaves tea at minus one. Both observations are reproducible; neither requires a story about how confident the assistant sounded.

        Eight contract tests, including input identity and rejected writes
        Codepython
        import unittest
        
        class ReservationTests(unittest.TestCase):
            def test_success_returns_a_separate_inventory(self):
                stock = {"tea": 3, "coffee": 4}
                updated = reserve(stock, "tea", 2)
                self.assertEqual(updated, {"tea": 1, "coffee": 4})
                self.assertEqual(stock, {"tea": 3, "coffee": 4})
                self.assertIsNot(updated, stock)
        
            def test_exact_stock_is_allowed(self):
                self.assertEqual(reserve({"tea": 3}, "tea", 3), {"tea": 0})
        
            def test_rejection_preserves_inventory(self):
                stock = {"tea": 3}
                with self.assertRaises(ValueError):
                    reserve(stock, "tea", 4)
                self.assertEqual(stock, {"tea": 3})
        
            def test_zero_and_negative_quantities(self):
                for quantity in (0, -1):
                    with self.subTest(quantity=quantity):
                        stock = {"tea": 3}
                        with self.assertRaises(ValueError):
                            reserve(stock, "tea", quantity)
                        self.assertEqual(stock, {"tea": 3})
        
            def test_non_integer_quantities(self):
                for quantity in (True, False, None, "1", 1.0):
                    with self.subTest(quantity=quantity):
                        stock = {"tea": 3}
                        with self.assertRaises(TypeError):
                            reserve(stock, "tea", quantity)
                        self.assertEqual(stock, {"tea": 3})
        
            def test_unknown_product(self):
                stock = {"tea": 3}
                with self.assertRaises(KeyError):
                    reserve(stock, "coffee", 1)
                self.assertEqual(stock, {"tea": 3})
        
            def test_sold_out_product(self):
                stock = {"tea": 0}
                with self.assertRaises(ValueError):
                    reserve(stock, "tea", 1)
                self.assertEqual(stock, {"tea": 0})
        
            def test_later_reservation_uses_the_returned_state(self):
                original = {"tea": 3}
                first = reserve(original, "tea", 1)
                second = reserve(first, "tea", 1)
                self.assertEqual(original, {"tea": 3})
                self.assertEqual(first, {"tea": 2})
                self.assertEqual(second, {"tea": 1})
        
        
        if __name__ == "__main__":
            unittest.main()

          Minutes 35–41: recover without losing the verified result

          Suppose the assistant proposes a new reservation class at minute 36. Ask which remaining requirement it satisfies. If the current helper already meets the exercise contract, keep the tested version and describe the class as optional follow-up. If a real defect remains, name its failing input, make a focused change, and rerun the relevant checks. Avoid adding an unexecuted improvement just because its explanation sounds complete.

          When the repair is still unfinished, report the exact checkpoint reached: the failure reproduces, the contract is agreed, and a particular test remains red. Show the smallest useful next change. If a wider edit made the behavior unclear, return to the last understood version in your local practice workspace. During an actual assessment, follow the environment's rules and explain what you are doing to the interviewer.

            Minutes 41–45: explain the result and its boundary

            A useful handoff can be brief: The rejection happened after subtraction, so a failed reservation changed inventory. I moved validation first and return a copied dictionary on success. The eight test methods pass, and removing the copy makes two fail. That explanation connects a cause, a decision, and observed evidence. Python's unittest supports the equality, identity, and exception checks used to substantiate it. Python: unittest assertions and subtests

            Then state the boundary. The helper transforms one in-memory snapshot; it does not prevent two independent requests from spending the same database inventory. A real reservation service needs a storage-level concurrency design and integration checks. In your next rehearsal, use the timestamps to identify where your own process stalled. Change one allocation based on that observation instead of treating this particular split as an optimal formula.

              Frequently asked questions about interview time budgets

              Should I stop immediately when a checkpoint expires? Use it to make a decision, not to interrupt a necessary sentence. Name the missing evidence, reduce optional scope, and agree on the next step. If an interviewer changes the requirement, revise the plan openly.

              Can I let AI generate all the tests to save time? You can request tests when AI is permitted, but still verify the expected values and run them. Ask which case distinguishes a plausible wrong repair. A large test file is not the same thing as useful evidence.

              What changes in a shorter interview? Keep the same essential outcomes and choose a smaller exercise or fewer independent cases. Preserve time to execute the repair and explain what was verified. This 45-minute rehearsal is an example, not a requirement to finish every task on that clock.

                Sources & editorial notes

                This article was authored with AI using primary-source research and an automated technical review. It has not been reviewed by a human. Code examples are illustrative; run and verify them in your own environment.

                1. Python: dictionaries and Boolean types

                  Supports the shallow-copy behavior of dictionaries and the relationship between booleans and integers. Checked October 24, 2026; does not substantiate the proposed rehearsal timing.

                2. Python: unittest assertions and subtests

                  Documents unittest equality, identity, exception assertions, and subtests used in the executable practice example. Checked October 24, 2026.

                Put the reading into practice

                Work through an existing repository, review AI suggestions, and test the decisions behind your changes.

                Explore practice problems