 Hello everyone, myself Samprit Patel, assistant professor from Department of Computer Science and Engineering, Walchand Institute of Technology, Sholabur. In this video, we are going to see the second type of collection data types that is tuples. After this session of video, you will be able to understand the second type of collection data types in Python and you will be able to apply tuples in different applications. So starting with the introduction of tuples, tuple is a sequence of immutable Python objects. Immutable Python objects means once the tuple has been defined, you cannot change the elements in a tuple. So this is the basic difference between a tuple and a list. That is, lists are mutable, that is, the content of the elements of the list can be changed whereas the elements of the tuples cannot be changed and the lists are enclosed in square brackets whereas tuples are enclosed in parenthesis. So see the following example, there are three tuples that we have defined, tuple one, tuple two and tuple three. So you can see tuple one contains string values as well as numeric values. Tuple two contains the same elements that is the numeric values and tuple three contains characters. So like list tuple can also contain multiple element types or data types in a single tuple list. So syntax of creating tuple is tuple name which is equal to tuple element one and two enclosed in single course and separated by commas. This is the one way you can define a tuple and the second way to define a tuple is enclosed into round brackets that is parenthesis. We will see an example of creating a tuple. So say tuple one is equal to without using any parenthesis we will say a, b, c and another element will be p, q, r and the second tuple will be tuple two which will be enclosed in parenthesis and the elements will be in single code that is say d, e, f and separated by commas say x, y and z. So we will print both these tuples. So print tuple one and print tuple two. So we will run this code and see. So see this is the tuple one that is a, b, c and p, q, r and this is tuple two d, e, f and x, y, z. So the output you will see even if we define without parenthesis the output will be with parenthesis which denotes that this is a tuple. So moving forward is concatenating. So before going to concatenation of tuples we will see two things how to find whether the element is present in a tuple or not. So we will just clear this print statement and say if, so using if statement into double codes if a, b, c in tuple one so this indentation is important in python. So we will say print in double codes a, b, c is present in tuple one. So using if statement and directly using an element to check whether it is present in a number on word so it will give this particular statement. Now another thing is if you want to find out the length of the tuple so you can use the length alien function that is length of say we will find out the length of tuple two. So this is the syntax for this. So see the number of elements present in tuple two are two and that is the output of this particular print statement. So we can concatenate two different tuples. So for example this is tuple one and tuple two we have defined and we are printing both the tuples together using plus operator that is used to concatenate two different tuples. We see the example with the same tuples that we have defined that is tuple one and tuple two. So if you want to print both together it is like just tuple one plus tuple two. So this is one way we can concatenate a tuple. So see first we are getting a b c and p q r and then we are getting d e f and x y z. This is one way to concatenate a tuple another way is create a new tuple and assign the two tuples to this tuple one plus tuple two and just print tuple three. So it will give you the same output a b c and p q r. Now the third important thing is you have seen how to add an element in a list but being a tuple we cannot add an element to a list. For example if you want to add in tuple one index number one you want to add an element so if we say l m n. So this is defining the tuple one at the index location one we have to add l m n. So if we run this code you will get an error saying that tuple object does not support item assignment that is you cannot add element to a tuple once it is defined. Going forward take a minute and try to code the following problem statement write a program that contains two tuples student details and student marks and concatenate these details and marks of the student and display it. So as we have seen so we will change the values of so we will take student details that is first tuple we will define this tuple as say student name will be a b c its roll number will be one its department will be computer science and engineering and the college will be WIT solapur. So we cannot give this comma as comma is used to separate two elements. So we will say WIT okay now we will take second tuples for marks. So marks will be all integer numbers so we can directly give say 50 52 60 after that 45 and say 70 okay so we have to concatenate we have seen two methods so we will say use the second one say we will display is equal to student details using plus operator marks and we will just write print display so I guess there is a spelling mistake. So print display okay so we will run this code okay so the student details are displayed the name, roll number, department, college and the marks of five subjects. So these two different tuples have been concatenated. Now this is the answer if you want to see this is another possibility how we can concatenate two tuples we have directly used print statement and we have used operator sign between two tuples in print statement itself. Now nesting a tuple so if you see the syntax there is tuple one which have two element and there is tuple two which have two elements so tuple three we can directly pass the two tuples in it so we will see this example so see we have seen we will take the same example and we will insert these tuples as a tuple element so student details comma so we have to give this in quotation marks marks okay so we will print display okay so see we have used quotation marks therefore it is taking as a tuple element and not the tuple itself. So now if we remove the code and we will run now see these tuple elements the tuple element of student details and marks have been automatically assigned to display okay now deleting a tuple if you want to delete a tuple completely you can use a keyword dill that is d-e-l and you can delete the complete tuple so we will say here dill display and we will run you will definitely get an error that name display is not defined as you have deleted the tuple right so print statement won't be executing so these are some references I have used to create this particular video and presentation programming in python 3 of psn publications and core python programming of dream tech press you can also go through this books if you have any doubts about it thank you