MENU
Question -

What does ‘immutable’ mean ? Which data type in Phython are immutable.



Answer -

An immutable variable change of value will not happen in place. Modifying an immutable variable will rebuild the same variable. For example,
>>> x= 5
will create a value 5 referenced by
x x —> 5
>>> y = x
This statement will make y refer to 5 of x.
x
5
y
>>> x = x + y
As x being, immutable type, has been rebuild. In the statement expression of RHS will result into value 10 and when this is assigned to LHS (x), x will rebuild to 10. An Integer data type in python is immutable.

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×