In Python, data types are break in tow part, either mutable or immutable based on whether their values can be changed after they are created.
Mutable Types:
Mutable objects can be modified after their creation without changing their memory address. This means that operations can be performed directly on the object (same address) to alter its content.
Examples of built-in mutable types:
list: Ordered, changeable collection of items.
dict: Unordered, changeable collection of key-value pairs.
set: Unordered, changeable collection of unique items.
bytearray: Mutable sequence of bytes.
Immutable Types:
Immutable objects cannot be changed after their creation. Any operation that appears to modify an immutable object actually results in the creation of a new object with the modified value. The original object remains unchanged.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In Python, data types are break in tow part, either mutable or immutable based on whether their values can be changed after they are created.
Mutable Types:
Mutable objects can be modified after their creation without changing their memory address. This means that operations can be performed directly on the object (same address) to alter its content.
Examples of built-in mutable types:
list: Ordered, changeable collection of items.dict: Unordered, changeable collection of key-value pairs.set: Unordered, changeable collection of unique items.bytearray: Mutable sequence of bytes.Immutable Types:
Immutable objects cannot be changed after their creation. Any operation that appears to modify an immutable object actually results in the creation of a new object with the modified value. The original object remains unchanged.
Examples of built-in immutable types:
int: Integers.float: Floating-point numbers.str: Strings (sequences of characters).tuple: Ordered, unchangeable collection of items.frozenset: Immutable version of a set.bool: Boolean values (True/False).Read More