Exercise 2: A Third Function Reproducing the Same Bug Class — Possible Solution ==================================================================== THE NEW FUNCTION ------------------------------ def format_receipt_line(price_dollars): return f"Total due: ${price_dollars:.2f}" Composed directly with the chapter's own calculate_price_in_cents (which returns cents, not dollars): item = {'price_dollars': 19.99} cents = calculate_price_in_cents(item) # 1999 buggy_line = format_receipt_line(cents) # treats 1999 as dollars RESULTS ------------------------------ BUGGY composition: "Total due: $1999.00" (should read approximately $19.99 - the same class of unit mismatch as the chapter's own apply_discount_dollars example) FIXED composition (converting cents back to dollars first): def checkout_total_dollars(item): cents = calculate_price_in_cents(item) return cents / 100 fixed_line = format_receipt_line(checkout_total_dollars(item)) FIXED composition: "Total due: $19.99" WHY THIS WORKS AS AN ANSWER ------------------------------ This confirms the chapter's own finding isn't specific to apply_discount_dollars - any function downstream of calculate_price_in_cents that expects dollars reproduces the identical bug class, because the actual defect lives at the interface (an undocumented unit mismatch), not inside either individual function. Both format_receipt_line and apply_discount_dollars are, individually, completely correct - the bug only exists in how they're wired together, exactly the chapter's own point about composition versus unit-level correctness.