<jupyter_start><jupyter_text>Difference b/w Data Structures of Python (particularly : a TUPLE and a LIST) as understood by <NAME> under the able guidance of <NAME>. In Python tuples are _very similar_ to lists, however, unlike lists they are __IMMUTABLE__ meaning...(u know what that means). I would use (from now onwards) tuples to present things that shouldn't be changed, such as days of the week, or dates on a calendar. _GIST: LISTS(minus)MUTABILITY = TUPLES_A tuple is typically used specifically because of its property of _rigidity_.Another popular use for this according to me might be sequence unpacking, where we want to store returned data to some specified variables. (I'll give an example don't worry!)Only in-built methods supported by a Tuple are: - *__count__* - *__index__*Here are some follow-up code examples to better understand this _silly yet important(in the future) concept_<jupyter_code># Creating a tuple
abhiTuple = (7,8,4, 'sup?') #yes, we can mix object types in a tuple.
abhiTuple[3] 
abhiTuple[1:] #methods like indexing and slicing [and reversing which in fact is a specail instance of slicing in which we do...lemme show you next!]
abhiTuple[::-1] #and VOILA! tuple reversed, just like a list would be, but here comes the big difference!<jupyter_output><empty_output><jupyter_text>An example of a situation where using a TUPLE helps us in  preserving integrity of data...<jupyter_code>def example():
    return 37, 73

x, y = example()
print(x,y)

# in the above case, we have used a tuple and cannot modify it... and
# we definitely do not want to!<jupyter_output>37 73<jupyter_text>The return of the IMMUTABLE!It can't be stressed enough that tuples are immutable. This is the crucial point my niBBa's To drive that point home:<jupyter_code>#INTENTION: To change an element of the tuple "abhiTuple" after it has been declared.
#TOPROVE: IMMUTABILITY of a "smol" tuple
#RESULT: an error (as expected, what more harm could it have done to you ?)

abhiTuple[1] = "itWon'tChange"<jupyter_output><empty_output><jupyter_text>*givin' the __i told you so look!!!!__*~~~~---------------------------------------------------------------------------TypeError                                 Traceback (most recent call last) in       4 RESULT: an error (as expected, what more harm could it have done to you ?)      5 '''----> 6 abhiTuple[1] = "itWon'tChange"TypeError: 'tuple' object does not support item assignment~~~~ It is because of this immutability, that __tuples can't grow__(*like puberty struck 13 y'olds*). Once a tuple is made we can not add (*or in gentlemanly terms: __append anything__*) to it.<jupyter_code>#INTENTION: To append an element to the tuple "abhiTuple" after it has been declared.
#TOPROVE: IMMUTABILITY of a "smol" tuple
#RESULT: an error (as expected, what more harm could it have done to you ?)

abhiTuple.append("giveUp Human, itWon'tChangeStill!")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1059625212947189, 'fraction_numerical': 0.007155025553662692, 'mean_word_length': 4.1239092495637, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '608000', 'license': 'MIT', 'n_tokens_mistral': 883, 'n_tokens_neox': 848, 'n_words': 398, 'path': 'Misc. Practice Code Junk/diffBWtupleAndList.ipynb', 'repo_name': 'PseudoCodeNerd/learning-python', 'size': '2954'}