+ 1

immutable & tuples

please explain those topic with programming which is written above

25th Feb 2018, 2:46 PM
subham gupta
subham gupta - avatar
4 Answers
+ 11
To expand on the really good technical answers already posted here, I thought I'd share a way to make this word make more sense, based on what you already know about other words. One way to remember the meaning of "immutable" is to first associate the word "mutable" with the word "mutate". Think X-Men "mutants", Teenage "Mutant" Ninja Turtles, or how you might have called your sibling a "mutant freak" when arguing as kids. 😂 These all apply to being different or having changed from some other form. Now, if you know that "mutate" means "to change", then "mutable" means "can be changed" or "is changeable". Next, it helps to know that the latin prefix "im" negates the root word that follows to carry an opposite meaning. Examples of words with the "im" prefix: - impossible means not possible - impatient means not patient - imperfect means not perfect - impolite means not polite This pattern can be applied to many other words, such as, immoral, imbalance, impotent, and so on and so forth. Therefore, "immutable" means "not mutable", or rather, as established earlier, "not changeable". Hopefully, with this rather boring pseudo-etymology lesson, the word "immutable" will now sound less strange and more familiar.
25th Feb 2018, 5:55 PM
David Carroll
David Carroll - avatar
+ 5
An immutable object is one that cannot be changed once it is created. A tuple is a list(in a way) that you cannot alter once created, that is you cannot add elements to it and you cannot change the value of existing elements. Example: tuple_a = (1, 2, 4) tuple[0] = 9#This is not allowed!
25th Feb 2018, 4:50 PM
David Akhihiero
David Akhihiero - avatar
+ 4
Please add Python as a tag in your question
25th Feb 2018, 4:51 PM
David Akhihiero
David Akhihiero - avatar
+ 3
immutable means unable to modify or delete(unchaged) tuple in python is read only.we can declare tuple only once. after that ,not possible to update or delete values of tuple . ch=('a','b','c') print(ch) print(ch[1]) #gives error,unable to modify ch.append('d') #gives error,unable to delete del ch[0]
25th Feb 2018, 4:53 PM
Manorama
Manorama - avatar