tax_rate = 0.05 already exists. Write a function price_with_local_tax(amount, tax_rate) that takes its OWN tax_rate parameter (shadowing the global one inside the function body) and returns amount + amount * tax_rate, using only the local parameter, never the global. Then write a second function price_with_global_tax(amount) that has no tax_rate parameter and instead reads the module-level tax_rate directly, returning the same formula. This demonstrates that a local parameter of the same name shadows an outer/global variable within its own function.price_with_local_tax(100, 0.2)
120.0
Uses the passed-in tax_rate 0.2, ignoring the global 0.05.
price_with_global_tax(100)
105.0
No local tax_rate parameter exists, so it falls back to the global 0.05.
A parameter name automatically becomes a local variable that shadows any same-named global for the duration of the function.
price_with_global_tax can read the global directly since it is only reading, not reassigning, so no global keyword is needed.