✏️ Explanatory Question

Differentiate between mutable and immutable objects in Python language with example.

👁 251 Views
📘 Detailed Answer
251
Total Views
10
Related Qs
0%
Progress
💡

Answer with Explanation

Ans. Every variable in Python holds an instance of an object. There are two types of objects in Python, Le Mutable and Immutable objects. Whenever an object is instantiated, it is assigned a unique object id The type of the object is defined at the runtime and it can't be changed afterwards. However, its state can be changed if it is a mutable object.

For example, int, float, bool, string, unicode, tuple are immutable objects in Python. In simple words, an immutable object can't be changed after it is created. Lists, dictionaries and sets are mutable types.