Why does every instance method in Python require `self` as its first parameter? What would break if `self` were omitted?
Think about your answer, then reveal below.
Model answer: Without `self`, a method has no reference to the specific instance it is operating on. It cannot access or modify that instance's attributes. If you wrote `def deposit(amount): balance += amount`, it would fail because `balance` is not defined as a local variable — it lives on the instance. `self.balance` is the correct reference, and `self` is how the method receives that instance. Without it, Python would treat the method like a plain function with no connection to any object's data.
The need for explicit `self` is a design choice Python made (many other OOP languages implicitly pass `this`). It makes the connection between method and instance visible and explicit. When Python calls my_account.deposit(50), it translates this internally to BankAccount.deposit(my_account, 50) — the instance is always the first argument, and `self` is the parameter that receives it. Omitting `self` would cause the method to receive its first real argument (like `amount`) as `self`, producing confusing errors, and the method would have no way to access the instance's attributes.