tuples are another type of data sequences but differently to lists they are immutable
tuples cannot be changed or modified you cannot append or delete elements
the syntax that indicates you are having a tuple and not a list is
that the tuples elements are placed within parentheses and not brackets
by the way the tuple is the default sequence type in Python so if I enlist three values
here the computer will perceive the new variable as a tuple we could also say that three values
will be packed into a tuple for the same reason we can assign a number of values to the same
number of variables do you remember we went through that a few lectures ago on the left
side of the Equality sign we just added a tuple of variables and on the right a tuple of values
that's why the relevant technical term for this activity is tuple assignment
in the same way we did for lists we can index values by indicating their position in brackets
that's why we obtained the first number from the tuple X namely 40 in addition we can also
place tuples within lists and then each tuple becomes a separate element within the list
tuples are similar to lists but there are some subtle differences
we should not overlook they can be quite useful when dealing with different comma
separated values for example if we have age and years of school as variables
and I have the respective numbers in a string format separated by a comma hence
the name comma separated values the split method with the proper indication within the
parentheses will assign 30 as a value for age and 17 as a value for years of school
we can print the two variables separately to check the outcome
everything seems to be correct awesome
last functions can provide tuples as return values this is useful because a function
which can only return a single value otherwise can produce a tuple holding multiple values
check this code
I will input only the length of the side of a square and
as an output the square info function will return a tuple
the tuple will tell me the area and the perimeter of the square
you you this is how we can work with tuples in Python thanks for watching