AAmit’s LibraryLEARN · PRACTISE · REFLECT

Entrepreneurship × Programming

Business lens: Entrepreneurship · Technology lens: Programming

Reading scope: Original fictional teaching. Selected documentation and same-author checks are not independent editorial validation.

A tiny pricing script can change the promise

A fictional maker sells customised accessories through a pricing script. The script produces a total quickly, but customers occasionally see a different amount in the confirmation email. Entrepreneurship and programming meet at the rule that turns an offer into a dependable transaction. Define the pricing policy before implementing arithmetic: whether discounts apply per item, how totals are rounded and which version applies to an accepted order. Faster calculation does not excuse ambiguous rules. Start with a small function and a few deliberately difficult examples. A founder should be able to explain the output to a customer without saying that the computer simply decided it.

Represent the intended arithmetic

Product defines the offer, Finance specifies rounding and Customer Service needs a reproducible explanation. Keep input representation, calculation and display separate. Python’s decimal documentation explains decimal arithmetic and explicit rounding controls; constructing values from intended decimal strings avoids importing an unintended binary floating-point representation. That choice still does not determine the correct commercial policy. State the rounding mode and rounding stage. Do not infer a jurisdiction’s tax rules from a programming example. A fictional pricing exercise can demonstrate differences between policies without endorsing either one for an actual sale. Preserve the rule version with the accepted order.

Worked rounding alternatives

The invented unrounded unit price is ₹19.995, and the customer buys three units. Under stipulated half-up rounding to two decimal places per unit, the rounded unit price is ₹20.00 and the total is ₹60.00. Under stipulated rounding only after multiplication, the unrounded subtotal is ₹59.985 and the rounded total is ₹59.99. The policies differ by ₹0.01 for this order. Both calculations are internally consistent with their stated stage and mode. The difference is not evidence of a defective arithmetic library. A specification that leaves the stage unstated can produce two implementations that both appear reasonable while disagreeing on the customer’s total.

Corrections need a stable basis

Suppose the customer returns two units. Applying the same per-unit policy gives ₹40.00, while multiplying the unrounded unit price by two and then rounding gives ₹39.99. Again, the difference is ₹0.01. The return rule must be consistent with the actual accepted transaction and applicable business requirements, not chosen opportunistically to benefit the venture. Store the original charged amount and pricing version. A later code improvement should not silently recalculate historical orders under a new policy. Test edge cases including zero quantity, invalid input and a discount boundary. These examples illustrate specification and arithmetic, not a complete refund, taxation or accounting implementation.

Practice a price specification

Use the existing break-even spreadsheet lesson to separate unit contribution assumptions from customer price calculation. Add a small specification table for the ₹19.995 example: representation, quantity, rounding stage, mode and displayed total. Reproduce both sale and return alternatives and identify the one-cent difference. Your portfolio should include examples that an implementation must match and a rule for retaining the accepted version. This connects existing bounded practice to a programming design task; it does not add a tested checkout engine or claim legal correctness. If you write a local function, record its actual outputs separately from the stipulated expected values in this reading.

Enquiry and progressive learning

Who approves pricing rules, and Whom should a developer consult about returns? Whose accepted price is preserved? What is rounded, Where is the rule version stored, and When does a change apply? Why can decimal arithmetic still produce different totals? Which stage explains the discrepancy? How will edge cases be checked? Foundation learners distinguish a displayed price from an intermediate value. Undergraduate learners calculate both policies and specify examples. Postgraduate learners critique historical reproducibility, change control and boundary conditions. Research learners design an auditable comparison of pricing specifications with independently checked expected results. For revision, explain why selecting an exact representation cannot resolve an unstated business rounding rule.

Study questions and answers

What are the two sale totals?

Per-unit half-up rounding gives ₹60.00. Subtotal half-up rounding gives ₹59.99.

Marking guide: Credit 60.00 per-unit and 59.99 subtotal totals under declared half-up policy.

What produces the one-cent difference?

The stage of rounding: each unit before multiplication versus the subtotal after multiplication.

Marking guide: Explain rounding before versus after multiplication as one-cent cause.

Why retain the original pricing version?

To reproduce accepted transactions and prevent later rule changes from silently rewriting historical prices.

Marking guide: Retain original rule version to reproduce transactions; later changes must not silently rewrite prices.

Practice task

Specify a fictional pricing function with decimal inputs, explicit rounding policy and versioned examples.

Practice bridge

  1. Specify a fictional pricing function with decimal inputs, explicit rounding policy and versioned examples.
  2. Reproduce the worked arithmetic, change one assumption and label invented evidence separately from actual practice observations.

Open connected lab

Boundary: Original fictional exercise connected to an existing bounded or guided lesson. No new executable fixture, external platform execution or catalogue lab claimed.

Sources and further reading

  • Python decimal arithmetic documentation
    Scope: Selected decimal representation and rounding sections checked; not a complete pricing, taxation or accounting implementation review.
    Access: Free public official documentation

Related chapters

Interactive practice

Open workshop · Open runnable practice · Open lab lab-03

Open interactive matrix reading