Q: I heard Tuples are pretty basic, similar to a List without all the features. Why cover them?
A: There is a purpose for Tuples, this is where we get our start and go in-depth !
A tuple is specified as a comma-separated list of values, which may be enclosed in parentheses. tuple( 'item',)
Similar to lists, tuples are sequences of arbitrary items. Unlike lists, tuples are immutable, meaning you can’t add, delete, or change items after the tuple is defined. So, a tuple is similar to a constant list. They are used everywhere in Python, because they allow for patterns that are hard to reproduce in other languages. The values need not all be of the same type. A value can also be another tuple.
Here are some examples:
>>> # Create a Tuple
>>> empty_tuple = ()
>>> empty_tuple
()
>>> # A One item tuple
>>> Level1 = 'Kreestuh',
>>> Level1
('Kreestuh',)
>>> # Multiple element tuple
>>> # Follow all elements except the last element with a comma
>>> LevelOne = 'Kreestuh', 'Wendell', 'Grizzle'
>>> LevelOne
('Kreestuh', 'Wendell', 'Grizzle')
>>> L1Tech = ('Level', 'One', 'Tech')
>>> #You can assign multiple variables at once
>>> a, b, c = L1Tech
>>> a
'Level'
>>> b
'One'
>>> b
'One'
>>> c
'Tech'
>>>
Q: Yeah, that's kind of what I expected, Kinda boring... But what about this unpacking? What's it about?
A: I will cover more on unpacking and it's use in a post below ! We will use Tuple as records and storing coordinates and other cool things !
Code_On_Code_Warrioirs