Code Safety · interview question
A bug appears around mutation and copying. What is the strongest first debugging move?
Multiple choiceHardchapter-3-curatedpremiumcode-safetymutation-and-copying
defaults = {"currency": "USD"}
payload = defaults.copy()
payload["currency"] = "EUR"
print(defaults, payload)Answer and explanation
Correct answer
C. Trace one concrete example, inspect the state transitions, and compare them to the intended rule before rewriting anything.
Why
That approach is reliable because it creates evidence. Shared mutable structures make later behavior depend on hidden history.
Test yourself on Code Safety
A free test with instant, explained results. No account needed.
More Code Safety questions
- Another engineer will maintain this code later. What choice helps the most around mutation and copying?
- What production risk should you worry about most if mutation and copying is handled lazily?
- A senior interviewer asks for one tradeoff behind mutation and copying. What is the strongest follow-up?
- What do interviewers usually hear as a strong signal when you discuss mutation and copying well?
- When is mutation and copying being used in the wrong way?
- Which option describes the most likely pitfall around mutation and copying?