 Hello. My name is Samprit Patel, Assistant Professor, Department of Computer Science and Engineering, Vulture Institute of Technology, Sholapur. Today, we are going to learn about the third type of collection data types that is set. In this video, you'll be able to understand different types of collection data types in Python, and you'll be able to apply sets in different applications. So, what are sets? Set is a collection of elements which are not in an ordered sequence. Set in Python is a data structure which is equivalent to that in mathematics. In sets, none of the elements can be duplicated, and nor the elements are mutable. That is, the elements cannot be changed or updated. But a set as a whole is a mutable data type. As the elements of set doesn't have any index value, the sets in Python does not support indexing and slicing. So, how to create a set? Set can be created by two ways. One is using a set function, and another is directly defining the elements using curly braces. So, the elements in the set are separated with commas. So, see the syntax. The first type is using the set function. When we are using a set function, we have to enclose the elements into square brackets. And if we are directly assigning the elements to a set, then curly braces are used. We'll see a direct example of this. So, see, a set one is declared, and it is defined using a set function. The set function is enclosed first with brackets, and inside those brackets, the elements are enclosed in square brackets. And there is another set that is the second type of defining a set. Using the curly braces, we have directly assigned the elements to set two. Now, if we run this program, see, this is the first set, which we have defined using a set function, and this is the second set, which we have defined by directly assigning the elements to a set. The next operation is adding items to a set. To add an item or an element to a set, we can use add function. So, the syntax is set name dot add, and in brackets, the element name. So, we'll see. We'll add an element to set two. So, set two dot add, and into brackets, we will add, say, L M N. And now we'll again print set two. We'll run this code, okay? So, in the second print of set two, L M N is being added. Now, adding the element, it will be added directly to the set, but not specifically to any index value. It will be added randomly at any place in the set element. Moving forward, how to remove an element from the set? To remove an element from the set, we have to use discard function. So, the syntax is set name dot discard, and into brackets, the element you want to remove. So, we'll see. Again, we'll remove an element from set two. So, set two dot discard. And in the brackets, we will assign an element which we want to remove, say, PQR. And now, we will print set two. So, I'm keeping the print, all the print statements, so that you can compare and get to know that what is happening. So, see, the initial set two was defined with x, y, z, a, b, c, and PQR. Then, we added an element using add function and element L M N. Now, using the discard function in the last print statement or print line, the PQR has been discarded from the set two. Now, the basic operations of set are union, intersection, and difference. So, to find the union of sets which returns all the distinct elements from both the sets. To use the union of the sets, we have to assign a new set, set three, which is equals to set one and using the pipeline symbol from your keyboard and set two. So, we'll see this operation using set one and set two. So, set three is equals to set one, the pipeline operator from your keyboard, and set two. Now, we'll print set three. So, all the distinct elements from both the sets have been displayed. So, set one has PQR, a, b, c, and x, y, z, and currently, set two is having x, y, z, a, b, c, and L M N. So, the distinct elements have been displayed. So, a, b, c, and x, y, z are repeated, but they have been displayed only once. The second basic operation is intersection of sets. This will return common elements from both the sets. And to define this, we have to use and operator. So, I'll just remove different set twos we have been defining here. Okay, so it will be easy to understand. Now, set three, using and operator, we'll find the same elements present in set one and set two. So, here it is a, b, c, PQR, x, y, z, all three. We'll just change one element and check again. So, see, only the same elements present are PQR and a, b, c, and those are displayed as an intersection of set. So, try to write a code for the given statement. You have to define two sets of your choice and display the intersection of those two sets. So, the answer for this is we have taken a set which has an elements, say, Monday, Tuesday, and Wednesday, and we have another set, b, which has an elements Wednesday, Thursday, Friday, Saturday, and Sunday. So, we have to find intersection. That is, it will return only the element which is common in days a and days b. So, we have taken a third set all days, where we are storing the intersection of days a and b, and it will be printing only Wednesday, as Wednesday has been repeated in both days a and days b. Moving forward, to find the difference of set, it will return distinct elements present only in the first set and not in the second set. So, we have to use the minus operator to find the difference of a set. So, we'll use the same set, just changing the operator, okay? So, the distinct element from set one is x, y, z, which has been displayed as a difference of set one and set two. Now, there is a last operation to compare two sets. So, it will check whether the set is a subset or superset. So, we can use this operator, that is less than equal to or greater than equal to, and this will return either true or false. These are some references I have been using to make this PPT, programming in Python 3 of PSN publications and core Python programming of DreamTechPress. I have also used a website, w3schools.com, for some resources. So, if you have any doubts regarding this topic, you can also go through these references to clear it off. Thank you.