- Objects are entities created by Python
- they have state (data)
- they have methods (functionality)
- state and methods are encapsulated into Objects
- Integers (int) are Objects
- Integers (int) have state - the value of the integer
- Integers (int) also have functionality
- knows how to add itself to another integer
- knows how to represent itself as a string (for visual output)
- Float (float) numbers are objects
- state -> value
- functionality -> add
- Any data type we have in Python is an object
- It has a state
- It has functionality
- These states/ functionality are called attributes
- Is used to access attributes of an object
- car.brand -> accesses the brand attribute of the car object
- car.model -> accesses the model attribute of the car object
- For attributes that represent functionality, we usually have to call the attribute to perform the action -> often supplying additional information (parameters)
- An object is mutable if its internal state (data) can be changed
- One or more data attributes can be changed
- for example: integers, floats, booleans...
- An object is immutable if its internal state cannot be changed
- The state of the object is "set in stone."
- for example: lists, dictionaries, sets...