Section 6 and unit 4, Interview Preparation

Tuple is not striclty an immutable object. It is true you cannot change the length of element in a tupple. But you can actually change the value of a tuple element. ex. would be if an element of tuple is a list.

>>> tup = (1,2,3,'tup',[1,2,3])

>>> tup[-1].append(92)

above being a valid opertation . atleast in python 3.6

It appears option 4 is incorrect for the interview prep course. for section 6 and unit 4.

According to the glossary in Python's official document, the definition of immutable:

An object with a fixed value. Immutable objects include numbers, strings and tuples. Such an object cannot be altered. A new object has to be created if a different value has to be stored.



When assigning integers to variable names, it creates a new object every time, that is the id of the object changes. 



For example,

num = 5

num = 6



Here the value of object 'num' hasn't changed from 5 to 6; just the object 'num' refers to a new object. This can be confirmed by checking the id. Hence, we can't replace integers in tuples as it is not ready to accept new ids. 

However, mutable objects can change their value but keep their id(). So, what happens for lists is that the id of the list remains the same, its value only gets modified.