CBSE Class 12 Computer Science Question 55 of 105

Python Revision Tour II — Question 4

Back to all questions
4
Question

Question 4

What do you understand by mutability ? What does "in place" task mean ?

Answer

Mutability means that the value of an object can be updated by directly changing the contents of the memory location where the object is stored. There is no need to create another copy of the object in a new memory location with the updated values. Examples of mutable objects in python include lists, dictionaries.
In python, "in place" tasks refer to operations that modify an object directly without creating a new object or allocating additional memory. For example, list methods like append(), extend(), and pop() perform operations in place, modifying the original list, while string methods like replace() do not modify the original string in place but instead create a new string with the desired changes.