Computers for accountable operations
Four connected lessons. Suggested planning allowance: 45–75 minutes each, plus setup. Prerequisites: arithmetic, Python functions and the related chapters. This estimate is not measured learner time. No external packages or input files are needed; the fixtures are readable in main().
Download and run locally
python3 operations_practice.py python3 -m unittest operations_practice_test.py
Keep all three files together. Compare the printed JSON with operations_expected.json. The website does not run Python. There are 24 scenario tests. Save changed cases separately; the expected JSON describes the original fixtures only.
Inventory: when and how much to reorder
Expected: Position 40, reorder point 52, order quantity 60.
An inventory decision separates physical stock from the commitments already recorded. On-hand stock is 30 units, on-order stock is 20 and backorders are 10. Inventory position is therefore 30 + 20 − 10 = 40 units. Using daily demand of eight units, lead time of five days and a supplied safety allowance of twelve gives a reorder point of 8 × 5 + 12 = 52. The stated policy triggers at or below that point and orders up to position 100. The suggested quantity is 100 − 40 = 60 units.
Predict these quantities before running reorder(). Change on-hand stock to 42: the position becomes 52 and still triggers. Change it to 43: the position becomes 53 and does not trigger. This boundary matters when a purchasing system converts an informal rule into an executable condition. Two systems using different equality conventions can issue different orders with identical records. Document the chosen rule in the procurement contract.
The twelve-unit safety stock is an input, not a statistically estimated service-level result. Demand and lead time are deterministic here. Do not claim the model protects against real demand variation merely because the variable is called safety_stock. Likewise the order-up-to target is supplied; the exercise does not optimise holding costs, shortage costs or supplier minimum quantities. A negative inventory position is possible if backorders exceed available and incoming stock. Explain why ordering more than the target quantity can then be consistent with the stated position policy.
Purchasing confirms open orders, the warehouse verifies physical stock, sales confirms backorders and finance reviews the cash commitment. Computers help combine those records and apply the same arithmetic repeatedly. Humans resolve stale orders, cancellations, disputed demand and exceptional shortages. Write a memo naming who can amend each input and whose approval releases an order. No order is placed by this program.
Foundation: distinguish stock from position. Undergraduate: reproduce both boundary cases. Postgraduate: critique deterministic lead time and propose monitoring. Research: design a comparison of reorder policies using a declared service measure and cost assumptions. Submit hand calculations, three changed-case outputs, an input-owner table and a limitation statement.
Queues: trace waiting rather than average it away
Expected: Five simultaneous jobs, capacity two: waits 0,0,1,1,2; mean 0.8 time slots.
A queue connects a customer's experience with operating capacity. In this lesson five jobs arrive at time zero and at most two begin service per time slot. Every job requires exactly one slot. Two jobs start at zero, two at one and the last at two. Waiting times are zero, zero, one, one and two, giving a mean of four divided by five, or 0.8 slots. Completion occurs one slot after each start. Waiting is not the same as time spent in the system.
Inspect fifo_queue(). It sorts arrivals by arrival time and then ID, which explicitly resolves simultaneous arrival ties. Jobs are appended to a first-in-first-out queue; up to capacity jobs are removed per tick. Predict the result with capacity five: every job begins immediately and average waiting becomes zero. Then test a single job arriving at seven. The implementation skips idle ticks and starts it at seven. An empty queue returns an undefined mean rather than pretending to have observed zero waiting.
Capacity here means parallel one-slot service opportunities, not an arbitrary quantity of work processed by one person. Real jobs may take unequal time, require different skills or abandon the queue. Priorities may override FIFO, and fairness can conflict with urgency. This deterministic discrete-time simulation has no random distributions, no fitted arrival process and no steady-state queueing-theory claim. Record those assumptions before translating slots into minutes.
Operations owns staffing, customer service explains delays, HR considers workload and finance evaluates capacity cost. A mean can conceal the last customer's two-slot wait. Report individual waits, maximum wait and throughput alongside an average; for the fixture the maximum wait is two. Discuss whether a priority customer should jump the line and whose policy authorises that choice. A computer can apply a policy consistently while still applying a poor policy.
Foundation: narrate the five jobs. Undergraduate: reproduce the trace and capacity sensitivity. Postgraduate: critique FIFO and equal service times. Research: propose an event-level dataset and an ethical evaluation of alternative scheduling policies. Submit a time table, changed-case prediction, actual trace and a recommendation balancing cost, fairness and customer experience.
Project schedules: dependencies, slack and assumptions
Expected: Project duration seven; A→B→D has zero slack; C has two units of slack.
A project schedule models which work must finish before other work starts. Task A lasts two time units. B lasts three and follows A. C lasts one and also follows A. D lasts two and follows both B and C. Earliest starts are A at zero, B and C at two, and D at five. D finishes at seven. These values are planning arithmetic, not a promise that a real project will finish on that date.
Read schedule() and draw the dependency network. It processes only tasks whose predecessors already have calculated finish times. If no pending task is ready, the dependency graph contains a cycle. Unknown predecessors and duplicate identifiers are rejected. These checks prevent an apparently plausible date from being generated from an incoherent graph. Positive integer durations are required by this particular classroom contract.
The backward pass computes latest starts using a common project-end milestone. A, B and D have zero slack; C has two units. Zero-slack tasks deserve attention because delaying them can delay the project under the stated assumptions. The result lists zero-slack tasks, not a general enumeration of every possible critical path. Change C's duration from one to five. The project now lasts nine, C becomes critical and B has two units of slack. This demonstrates why a critical sequence is conditional on current estimates.
The model allows B and C to run simultaneously. If the same employee must perform both, that schedule may be infeasible even though dependencies are satisfied. Resource levelling, calendars, holidays, cost, uncertainty and multiple projects are outside this implementation. A manager should compare the mathematical network with actual availability before assigning dates. Technology helps expose dependencies; consultation determines whether those dependencies and estimates describe the work.
Foundation: explain why D cannot start at three. Undergraduate: reproduce earliest and latest times. Postgraduate: add a resource-conflict critique and escalation policy. Research: propose a method for studying estimate revisions and project outcomes without treating every correlation as causality. Submit the network, baseline times, changed C case, a resource assumption register and a communication plan assigning owners to each milestone.
Process maps: accountable transitions and exceptions
Expected: Sales submits; finance approves; operations dispatches. Premature dispatch and wrong departments are rejected.
A process map describes the permitted route of work and the people responsible for moving it. This exercise starts in new, moves to review after sales submits, moves to approved after finance approves and moves to shipped after operations dispatches. Finance can instead reject a reviewed request, creating a terminal rejected state. Read TRANSITIONS as a compact executable map: each pair of current state and action identifies a next state and an authorised department label.
Predict the three-step successful trace before running process(). Each trace entry records the prior state, action, role and next state. Try dispatching from new: the action is illegal in that state. Try finance submitting: the transition exists but the role is wrong. Try dispatching after rejection: the terminal state has no such outgoing transition. Explain why checking sequence and checking ownership are separate responsibilities.
The role labels are supplied strings, not authentication. A caller can claim to be finance; this program cannot verify that identity. The trace exists only in memory and is not a durable audit trail. State is recreated for each call, and a failure raises an exception rather than saving partial work. These boundaries matter when someone asks whether the lesson is ready to handle live orders. It is an executable classroom map, not an ERP service or a BPMN execution engine.
Sales owns completeness at submission, finance owns its approval criteria and operations owns release after approval. The implementation checks none of those departments' deeper business criteria: an approval action could still be mistaken. Write a checklist for the evidence needed before each action. Specify who handles a disputed rejection, whom a delay affects, whose decision is final, when escalation happens and how correction is recorded. Human judgement remains necessary even when the sequence is automated.
Foundation: narrate the states in ordinary language. Undergraduate: reproduce successful and rejected traces. Postgraduate: design correction, appeal and authenticated authorisation controls. Research: propose an observable measure of handoff failures and a study design that includes workload and case complexity. Submit a state diagram, three exception tests and a departmental consultation memo. The separate BPMN Handoff catalogue entry remains a brief; this lesson does not relabel it as completed.
Further free official reading
- Python deque — queue operations.
- Python graphlib — dependency ordering.
- MIT operations syllabus — previously reviewed course scope; it is not validation of this code.
Documentation pointers are further reading, not newly audited programmes or certificate offers. Each exercise uses its own explicit classroom contract. Attempt flags are self-reported practice, not automatic grading.