Mutability and Immutability
Mutability and Immutability
In [1]:
In [22]:
# Insert
# Delete
# Update
In [37]:
In [24]:
# Indexing
In [25]:
Out[25]:
In [26]:
a[7]
Out[26]:
# Mutability : Any entity is said to be mutable if I can edit the elements inside it.
In [28]:
In [29]:
# Mutable Datatypes : The datatypes in which we can edit the data stored inside them ar
e known as
# Mutable Datatypes.
In [30]:
# Immutable Datatypes : the datatypes in which we can't edit the data stored inside the
m are
# known as immutable Datatypes.
In [31]:
id(a)
Out[31]:
3004529326984
In [33]:
Out[33]:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
In [34]:
id(a)
Out[34]:
3004529334280
In [35]:
a = ["Divyanshu","Yash"]
In [36]:
id(a)
Out[36]:
3004530273928
In [39]:
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
In [40]:
id(a)
Out[40]:
3004529333768
In [43]:
In [44]:
Out[44]:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
In [45]:
a[3] = "Yash"
In [46]:
Out[46]:
In [47]:
id(a)
Out[47]:
3004529333768
In [ ]:
In [ ]:
In [53]:
In [49]:
x = 2
In [50]:
id(x)
Out[50]:
140714545553840
In [51]:
x = 3
In [52]:
id(x)
Out[52]:
140714545553872
In [ ]: