Python's core type architecture enforces immutability on specific built-in data types, meaning that the object’s internal value cannot be modified once instantiated. Both integer (int) and string (str) objects are immutable. For instance, concatenating a string or incrementing an integer does not modify the original memory reference; instead, Python evaluates the expression, allocates new memory, and binds the variable name to the resulting object. Tuples and frozen sets are also immutable sequence/collection types in Python. In contrast, list and dictionary (dict) are mutable containers whose elements or key-value entries can be altered, appended, or purged dynamically in place without altering the container's object reference ID. Therefore, integers and strings represent the immutable types among the given choices.
[Reference: JNCIA-DevOps Study Guide — Python Data Types: Immutability and Memory Characteristics., ]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit