Introduction (Objects, Values, and Types)
All the data in a Python code is represented by objects or by relations between objects. Every object has an identity, a type, and a value.
Identity
An object’s identity never changes once it has been created; you may think of it as the object's address in memory. The is operator compares the identity of two objects; the id() function returns an integer representing its identity.
Type
An object’s type defines the possible values and operations (e.g. "does it have a length?") that type supports. The type() function returns the type of an object. An object type is unchangeable like the identity.
Value
The value of some objects can change. Objects whose value can change are said to be mutable; objects whose value is unchangeable once they are created are called immutable.
Mutable and Immutable Data Types in Python
- Some of the mutable data types in Python are list, dictionary, set and user-defined classes.
- On the other hand, some of the immutable data types are int, float, decimal, bool, string, tuple, and range.
We can easily check those properties by brief code.
Above contents copy from here!