Intermediate·10 min·intermediate · oop
Classes & Objects
Classes & Objects
A class is a blueprint. Each instance holds its own state.
Key pieces
__init__— runs when you create an instance; sets initial state onselfself— refers to the current instance__repr__— controls how the object prints
Try it
- Add a
transfer(self, other, amount)method that moves money between accounts. - Make
balancea property that can't go below zero.