Exercise 1: Renaming distance_fee to extra_charge — Possible Solution ==================================================================== THE RENAME ------------------------------ def calculate_international_shipping_renamed(weight_kg, distance_km): base_cost = weight_kg * 2.5 extra_charge = weight_kg * 0.1 # the same bug, renamed variable return base_cost + extra_charge The identical bug (computed from weight_kg instead of distance_km) is kept exactly as it was - only the variable's own name changed, from distance_fee to extra_charge. RUNNING THIS CHAPTER'S OWN CONSISTENCY CHECK ------------------------------ line: extra_charge = weight_kg * 0.1 # the same bug, renamed variable RHS contains the word "distance": False Technically, the check still returns False - correctly flagging that the RHS doesn't contain "distance." But this result is now misleading about WHY the check worked. THE LIMIT THIS REVEALS ------------------------------ This chapter's own original check worked because the word "distance" to search for came directly FROM the variable's own name - distance_fee promised "distance" simply by being named that. With extra_charge, there is nothing in the name itself suggesting the word "distance" is relevant at all - the only reason this exercise's own test still checked for "distance" is that I, writing the exercise, already knew (from this chapter's own original example) that this variable was SUPPOSED to be about distance. A reader encountering extra_charge = weight_kg * 0.1 for the first time, with no prior context, would have no way to know "distance" is the word they should be checking for - extra_charge gives no signal that anything is even suspicious, since "extra charge" could plausibly come from all sorts of inputs. WHY THIS CONFIRMS THE TECHNIQUE'S OWN REAL REQUIREMENT ------------------------------ This chapter's own consistency-check technique isn't magic - it only works when the NAME ITSELF supplies the word the check should look for. A vague name like extra_charge (or, worse, the original chapter's own cryptic fee) removes that supply entirely: the check becomes either impossible to construct from the name alone (as with fee), or only possible if the person writing the check already has outside knowledge of what "should" be true (as with extra_charge). The technique's own real power lives specifically in names precise enough to generate their own check - distance_fee does that; extra_charge does not, even though it's still more descriptive than a single letter. WHY THIS WORKS AS AN ANSWER ------------------------------ The rename is applied while deliberately preserving the exact same bug this chapter already verified, the check is re-run and its result reported honestly, and the limitation is explained by identifying exactly what information a reader would and wouldn't have without already knowing this chapter's own original example.