{"id":25533125,"date":"2022-07-12T20:00:28","date_gmt":"2022-07-12T14:30:28","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25533125"},"modified":"2023-05-18T16:14:15","modified_gmt":"2023-05-18T10:44:15","slug":"python-set-operations-union-intersection-and-difference","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/","title":{"rendered":"Python Set Operations: Union, Intersection, and Difference"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a058d533503c\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a058d533503c\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#What_Is_a_Set_in_Python\" >What Is a Set in Python?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#What_Are_Set_Operations\" >What Are Set Operations?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#The_Unions_of_Sets\" >The Unions of Sets<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#The_Intersections_of_Sets\" >The Intersections of Sets<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#The_Differences_Between_Sets\" >The Differences Between Sets<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<p>Let\u2019s take a look at how we can combine sets together to see what results we get! We\u2019ll take a look at the three-set operations that allow us to put sets together \u2013 python set union, intersection, and difference \u2013 and we\u2019ll even see what kind of results we get when we apply these operations to specific datasets. Before you know it, you\u2019ll be set operations master! Let\u2019s dive in. <span data-slate-fragment=\"JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIydGV4dCUyMiUzQSUyMlVzaW5nJTIwc2V0cyUyMGluJTIwUHl0aG9uJTIwY2FuJTIwYmUlMjBleHRyZW1lbHklMjBiZW5lZmljaWFsJTIwd2hlbiUyMGRlYWxpbmclMjB3aXRoJTIwbGFyZ2UlMjBhbW91bnRzJTIwb2YlMjBkYXRhJTJDJTIwZXNwZWNpYWxseSUyMGlmJTIweW91JUUyJTgwJTk5cmUlMjB0cnlpbmclMjB0byUyMGZpbHRlciUyMGl0JTIwZG93biUyMGFuZCUyMG9ubHklMjBrZWVwJTIwdGhlJTIwcmVsZXZhbnQlMjBpbmZvcm1hdGlvbi4lMjBUaGlzJTIwZ3VpZGUlMjB3aWxsJTIwY292ZXIlMjBhbGwlMjB0aHJlZSUyMHNldCUyMG9wZXJhdGlvbnMlMjAodW5pb24lMkMlMjBpbnRlcnNlY3Rpb24lMkMlMjBhbmQlMjBkaWZmZXJlbmNlKSUyMGFuZCUyMHdpbGwlMjBwcm92aWRlJTIwZXhhbXBsZXMlMjB0byUyMGdldCUyMHlvdSUyMHN0YXJ0ZWQlMjB1c2luZyUyMHRoZW0lMjBpbiUyMHlvdXIlMjBvd24lMjBwcm9qZWN0cy4lMjIlN0QlNUQlN0QlNUQ=\">Using sets in Python can be extremely beneficial when dealing with large amounts of data, especially if you\u2019re trying to filter it down and only keep the relevant information. <\/span><span data-slate-fragment=\"JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIydGV4dCUyMiUzQSUyMlVzaW5nJTIwc2V0cyUyMGluJTIwUHl0aG9uJTIwY2FuJTIwYmUlMjBleHRyZW1lbHklMjBiZW5lZmljaWFsJTIwd2hlbiUyMGRlYWxpbmclMjB3aXRoJTIwbGFyZ2UlMjBhbW91bnRzJTIwb2YlMjBkYXRhJTJDJTIwZXNwZWNpYWxseSUyMGlmJTIweW91JUUyJTgwJTk5cmUlMjB0cnlpbmclMjB0byUyMGZpbHRlciUyMGl0JTIwZG93biUyMGFuZCUyMG9ubHklMjBrZWVwJTIwdGhlJTIwcmVsZXZhbnQlMjBpbmZvcm1hdGlvbi4lMjBUaGlzJTIwZ3VpZGUlMjB3aWxsJTIwY292ZXIlMjBhbGwlMjB0aHJlZSUyMHNldCUyMG9wZXJhdGlvbnMlMjAodW5pb24lMkMlMjBpbnRlcnNlY3Rpb24lMkMlMjBhbmQlMjBkaWZmZXJlbmNlKSUyMGFuZCUyMHdpbGwlMjBwcm92aWRlJTIwZXhhbXBsZXMlMjB0byUyMGdldCUyMHlvdSUyMHN0YXJ0ZWQlMjB1c2luZyUyMHRoZW0lMjBpbiUyMHlvdXIlMjBvd24lMjBwcm9qZWN0cy4lMjIlN0QlNUQlN0QlNUQ=\">This guide will cover all three set operations (union and intersection, and difference) and will provide examples to get you started using them in your own projects.<\/span><\/p>\n<p><a href=\"https:\/\/entri.app\/course\/python-programming-course\/\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25531373 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Python-and-Machine-Learning-Rectangle-1.png\" alt=\"\" width=\"970\" height=\"250\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Python-and-Machine-Learning-Rectangle-1.png 970w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Python-and-Machine-Learning-Rectangle-1-300x77.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Python-and-Machine-Learning-Rectangle-1-768x198.png 768w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Python-and-Machine-Learning-Rectangle-1-750x193.png 750w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n<p><span data-slate-fragment=\"JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIydGV4dCUyMiUzQSUyMlVzaW5nJTIwc2V0cyUyMGluJTIwUHl0aG9uJTIwY2FuJTIwYmUlMjBleHRyZW1lbHklMjBiZW5lZmljaWFsJTIwd2hlbiUyMGRlYWxpbmclMjB3aXRoJTIwbGFyZ2UlMjBhbW91bnRzJTIwb2YlMjBkYXRhJTJDJTIwZXNwZWNpYWxseSUyMGlmJTIweW91JUUyJTgwJTk5cmUlMjB0cnlpbmclMjB0byUyMGZpbHRlciUyMGl0JTIwZG93biUyMGFuZCUyMG9ubHklMjBrZWVwJTIwdGhlJTIwcmVsZXZhbnQlMjBpbmZvcm1hdGlvbi4lMjBUaGlzJTIwZ3VpZGUlMjB3aWxsJTIwY292ZXIlMjBhbGwlMjB0aHJlZSUyMHNldCUyMG9wZXJhdGlvbnMlMjAodW5pb24lMkMlMjBpbnRlcnNlY3Rpb24lMkMlMjBhbmQlMjBkaWZmZXJlbmNlKSUyMGFuZCUyMHdpbGwlMjBwcm92aWRlJTIwZXhhbXBsZXMlMjB0byUyMGdldCUyMHlvdSUyMHN0YXJ0ZWQlMjB1c2luZyUyMHRoZW0lMjBpbiUyMHlvdXIlMjBvd24lMjBwcm9qZWN0cy4lMjIlN0QlNUQlN0QlNUQ=\">The set data structure in Python allows you to save unique values of any type and perform operations with them, such as combining or removing elements from the set. There are three common set operations in Python that can be performed using the &amp; (intersection), (union), and &#8211; (difference) binary operators, respectively. In this article, we will look at the different use cases and examples of how to utilize these Python set operations to combine, remove, or obtain specific elements from sets.<\/span><\/p>\n<div class=\"lead-gen-block\"><a href=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/03\/Python_PDF.pdf\" data-url=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/03\/Python_PDF.pdf\" class=\"lead-pdf-download\" data-id=\"&lt;strong&gt;25556851&lt;\/strong&gt;\">\n<p style=\"text-align: center;\"><strong>Download Python Programming Course Syllabus! <\/a><\/div><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_Is_a_Set_in_Python\"><\/span><strong>What Is a Set in Python?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A set is a collection of unique items in Python. Sets are created with curly braces, or the set function. Items in a set are unordered, meaning they can&#8217;t be sorted or indexed. However, you can loop through a set just like any other collection. The set&#8217;s size (the number of items it contains) does not change as it goes through different operations. To get a specific item from a set, use square brackets. If there are multiple items with the same index in the list, each one will be returned by using an integer after it that corresponds to its position in the list (for example apple at index 0 would be returned as 0 apple). To delete an item from a set, use del followed by an index number or list-of-indexes within square brackets. For example, del 3 will delete the item at index 3; del 0 will delete all elements of that type in this set. To combine two sets into one set, use union, intersection, or difference. Union takes the union of both sets and creates a new set that includes all the members of both sets.<\/p>\n<p style=\"text-align: center;\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">&#8220;Experience the power of our web development course with a free demo &#8211; enroll now!&#8221;<\/a><\/strong><\/p>\n<p>Intersection takes the intersection of both sets and creates a new set containing only those members which exist in both sets. Difference takes only those members which exist in either but not both sets and creates a new set containing them. To create a subset of a set, put the indices for the subset between square brackets. For example: will create a subset of three integers from a set containing six integers. One way to demonstrate the differences between these operations is by creating a diagram. Let&#8217;s start with python set union: Here we have our set of numbers from 1-5. Let&#8217;s say we wanted to make our set include 9 as well, so we could do 9 5 . Note that the order doesn&#8217;t matter here because everything still needs to be unique. Next let&#8217;s take intersection: We have a more strict ordering requirement here because anything in our original set (1-5) has to also be included in our new set (1-3). So 1 2 3 would work, but 1 2 wouldn&#8217;t since 2 isn&#8217;t present in 1-5 when we&#8217;re looking for overlap on things outside the range of 1-3.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"What_Are_Set_Operations\"><\/span><strong>What Are Set Operations?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In mathematics, a set is a collection of distinct objects, considered an object in its own right. Sets are one of the most fundamental concepts in mathematics and can be used to model situations in the real world. There are three main set operations: union and intersection, and difference. The union of two sets is the set that contains all elements that exist in either set but not both sets. The intersection of two sets is the set that contains only those elements that exist in both sets. The difference between two sets is the set that contains all elements present in one but not both sets. For example, given these two small lists from which we have removed duplicate elements (the elements found on both lists), we find their respective unions, intersections, and differences below<\/p>\n<p><strong><div class=\"lead-gen-block\"><a href=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/05\/1_merged-3_compressed.pdf\" data-url=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2023\/05\/1_merged-3_compressed.pdf\" class=\"lead-pdf-download\" data-id=\"25556851\"><\/strong><\/p>\n<p style=\"text-align: center;\"><button class=\"btn btn-default\">Free SQL Tutorial for Beginners &#8211; Download PDF<\/button><\/p>\n<p><strong><\/a><\/div><\/strong><\/p>\n<p>For example, 2 exists in only one of our two sets. However it is present in both sets\u2019 difference.<\/p>\n<p>This is because all three operations are disjoint\u2014they do not share any members. The union of two sets with no shared members is a disjoint union\u2014in other words, all members in either set or none at all. Similarly, if there are no shared members in the intersection of two sets then there will be nothing left over. The python set union of two sets may contain more than one member from each set if they have some commonality; however this may lead to duplication in the resulting list (such as when the first list has 3 unique items and 4 copies of 1 item). The difference of two sets may contain less than one member if they don&#8217;t share anything; however this may lead to empty results such as when one list has 4 unique items while another has 1 item.<\/p>\n<p style=\"text-align: center;\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">&#8220;Get hands-on with our python course &#8211; sign up for a free demo!&#8221;<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"The_Unions_of_Sets\"><\/span><strong>The Unions of Sets<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The union of two sets is the set of all elements that are in either set. The union of {1, 2, 3} and {2, 3, 4} is {1, 2, 3, 4}. We can also write this as {1, 2, 3} \u222a {2, 3, 4} = {1, 2, 3, 4}. The symbol \u222a represents the union of two sets. The picture below shows the union of two sets as the shaded area. Notice how the areas inside both shapes (the blue rectangle and green circle) will be part of the union. The intersection of two sets is the set of all elements that are in both sets. For example, if we have {1, 2}, {3}, and {4}, then the intersection would be just one element: 3. As with unions, we can represent intersections with a vertical line \u22c2 between two columns; for example, \u22c2{1, 2}\u22c3{3}\u22c3{4}. The symbol \u22c2 represents an intersection between two sets. A pictorial representation of an intersection would show only those points where lines from each shape overlap; for example, see the figure below. Finally, the difference of two sets is simply the set containing all elements in one set but not the other. The union of two sets is the set of all elements that are in either set. The intersection of two sets is the set of all elements that are in both sets.<\/p>\n<p>The difference between the two sets is the set of all elements that are in one set but not the other. In Python, these operations can be performed using the built-in set type. To get started, let&#8217;s define two sets: A and B. For example, if we had {1, 2} and {3}, then the difference would be just one element: 1. In math notation, it looks like this: {1} \u2212 {2}. It may seem confusing at first because this looks like subtraction when it\u2019s really addition! But remember that when you do subtraction in math you need to subtract on both sides! So the set {1} \u2212 {2} is equivalent to {1} + (-2). Now let&#8217;s look at an example of union and intersection, and difference between these two sets:<br \/>\nA={10, 12}; B={14}; Union={10, 12}; Intersection={14}; Difference={12}; The three different types of set operations are shown in the following diagram. Unions, intersections, and differences form basic building blocks for more complicated functions such as sorting or graphing data.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"The_Intersections_of_Sets\"><\/span><strong>The Intersections of Sets<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Just as the name suggests, a\u00a0python set intersection is where two sets intersect or overlap. The resulting set contains all of the elements that are common to both sets. In order to find the intersection of two sets, you&#8217;ll need to use the Python intersection method. This method takes two sets as input and returns a new set that contains only the elements that are common to both input sets. We can illustrate this with the following example: &gt;&gt;&gt; mySet = {1, 2} &gt;&gt;&gt; yourSet = {3, 4} &gt;&gt;&gt; mySet.intersect(yourSet) {3, 4}<br \/>\nThe difference between intersections and unions is that in unions each element appears at least once. For instance, if we have three sets A, B, and C with A={1}, B={2}, C={3}, then the union of these three sets would be {1, 2, 3}. On the other hand, intersections require at least one common element in each set before they will combine those elements into a new set. Let&#8217;s take a look at another example: &gt;&gt;&gt; mySet = {1, 2} &gt;&gt;&gt; yourSet = {3, 4} &gt;&gt;&gt; mySet.intersect(yourSet) {3, 4}<\/p>\n<p>&gt;&gt;&gt; ourUnion={1,2,3,4} # Note that the elements from yourSet are duplicated (e.g., 3).<br \/>\n&gt;&gt;&gt; ourIntersection={1} # Note that the only shared element is 1 which has been combined with itself (e.g., 1). &gt;&gt;&gt; ourDifference={3,4} # Note that there are no common elements so this set remains empty. It may seem redundant but I&#8217;m going to give an example <a href=\"https:\/\/entri.sng.link\/Bcofz\/yeoy\/ojyv\">using parentheses<\/a> again just for illustration purposes. If we had two sets A={1} and B={2,3}, the union of these two sets would be A={1,2,3} while the python set intersection would be A={1}. Notice how in this last case both sets contain 1 but only one contains 2 and 3. As such it makes sense that the result is just 1.<br \/>\nThe difference between intersections and unions is that in unions each element appears at least once.<\/p>\n<p style=\"text-align: center;\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">&#8220;Get hands-on with our python course &#8211; sign up for a free demo!&#8221;<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"The_Differences_Between_Sets\"><\/span><strong>The Differences Between Sets<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In set theory, two sets are equal if they have the same elements. That is, two sets A and B are equal if every element of A is also an element of B, and vice versa. The intersection of two sets A and B is the set of all elements that are both in A and in B. The union of two sets A and B is the set of all elements that are either in A or in B. It may seem like there&#8217;s a lot of overlap between these three operations but with small changes you can create very different outputs from your inputs.<br \/>\nFor example, take these four sets: {a}, {b}, {c}, and {d}. These sets are not equal because each one has a different number of elements. We can use Python&#8217;s set operators to find their python set intersection, unions, and differences . Let&#8217;s start by calculating the union for these four sets using this code:<\/p>\n<p>First we import pandas as pd, then we define our list of 4 sets (sets1) as a variable setlist. Next we define our output (set1_union) as a list object by setting it equal to . Then we iterate through our list setlist and add the values in any set containing more than 1 value into our new list set1_union. Once finished iterating through setlist, we print out the contents of set1_union which contains 17 items. Now let&#8217;s calculate the difference of these four sets using this code:<br \/>\nFirst we import pandas as pd, then we define our list of 4 sets (sets2) as a variable setlist. Next we define our output (set2_difference) as a list object by setting it equal to . Then we iterate through our list setlist and subtract the values in any set containing more than 1 value from our new list set2_difference.<br \/>\nOnce finished iterating through setlist, we print out the contents of set2_difference which contains 7 items.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><strong>Conclusion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Operations between sets are a fundamental part of many mathematical applications. In Python, the built-in set type implements these operations as well as many others. This tutorial explained how to use the union, intersection, and difference operators on sets in Python. With this knowledge in hand, you can start using sets in your own programs to solve all sorts of interesting problems. You should be able to figure out most of the other functions by reading their documentation or trying them out for yourself! Have fun learning about new ways to combine and divide data sets with Python&#8217;s powerful set operations. If you are interested to learn new coding skills, the Entri app will help you to acquire them very easily. Entri app is following a structural study plan so that the students can learn very easily. If you don&#8217;t have a coding background, it won&#8217;t be a problem. You can download the Entri app from the google play store and enroll in your favorite course.<\/p>\n<p style=\"text-align: center;\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/\" target=\"_blank\" rel=\"noopener\">&#8220;Ready to take your python skills to the next level? Sign up for a free demo today!&#8221;<\/a><\/strong><\/p>\n<h4><strong>Related Articles<\/strong><\/h4>\n<div class=\"table-responsive wprt_style_display\">\n<div class=\"table-responsive wprt_style_display\">\n<div class=\"table-responsive wprt_style_display\">\n<div class=\"table-responsive wprt_style_display\">\n<table class=\"table\" dir=\"ltr\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<colgroup>\n<col width=\"329\" \/>\n<col width=\"309\" \/><\/colgroup>\n<tbody>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Syllabus&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-village-field-assistant-vfa-syllabus-exam-pattern\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/step-by-step-guide-for-getting-a-job-as-a-python-developer\/42\" target=\"_blank\" rel=\"noopener\">A Step-by-Step Guide for Getting a Job as a Python Developer<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Mock Test&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-free-mock-test\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/why-python-is-used-for-data-science\/\" target=\"_blank\" rel=\"noopener\">Why Python Is Used For Data Science?<\/a><\/strong><\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Exam Date&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-exam-date\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/how-to-learn-python-at-home\/\" target=\"_blank\" rel=\"noopener\">How To Learn Python At Home?<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Video Course&quot;}\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/top-data-types-of-python-python-data-types\/\" target=\"_blank\" rel=\"noopener\">Top Data Types of Python<\/a><\/strong><\/td>\n<\/tr>\n<tr>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Application Form&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-apply-online\/\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/blog\/python-online-course\/\" target=\"_blank\" rel=\"noopener\">Best Online Python Course with Certificate<\/a><\/strong><\/td>\n<td data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;Kerala PSC VFA Study Materials&quot;}\" data-sheets-hyperlink=\"https:\/\/entri.app\/blog\/kerala-psc-vfa-study-material\/\"><a href=\"https:\/\/entri.app\/blog\/switch-case-in-python-switch-function\/\"><strong>Switch Case in Python<\/strong><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"modal\" id=\"modal25556851\"><div class=\"modal-content\"><span class=\"close-button\">&times;<\/span>\n\n<div class=\"wpcf7 no-js\" id=\"wpcf7-f25556851-o1\" lang=\"en-US\" dir=\"ltr\" data-wpcf7-id=\"25556851\">\n<div class=\"screen-reader-response\"><p role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"><\/p> <ul><\/ul><\/div>\n<form action=\"\/blog\/wp-json\/wp\/v2\/posts\/25533125#wpcf7-f25556851-o1\" method=\"post\" class=\"wpcf7-form init\" aria-label=\"Contact form\" novalidate=\"novalidate\" data-status=\"init\">\n<fieldset class=\"hidden-fields-container\"><input type=\"hidden\" name=\"_wpcf7\" value=\"25556851\" \/><input type=\"hidden\" name=\"_wpcf7_version\" value=\"6.1.4\" \/><input type=\"hidden\" name=\"_wpcf7_locale\" value=\"en_US\" \/><input type=\"hidden\" name=\"_wpcf7_unit_tag\" value=\"wpcf7-f25556851-o1\" \/><input type=\"hidden\" name=\"_wpcf7_container_post\" value=\"0\" \/><input type=\"hidden\" name=\"_wpcf7_posted_data_hash\" value=\"\" \/><input type=\"hidden\" name=\"_wpcf7cf_hidden_group_fields\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_hidden_groups\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_visible_groups\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_repeaters\" value=\"[]\" \/><input type=\"hidden\" name=\"_wpcf7cf_steps\" value=\"{}\" \/><input type=\"hidden\" name=\"_wpcf7cf_options\" value=\"{&quot;form_id&quot;:25556851,&quot;conditions&quot;:[],&quot;settings&quot;:{&quot;animation&quot;:&quot;yes&quot;,&quot;animation_intime&quot;:200,&quot;animation_outtime&quot;:200,&quot;conditions_ui&quot;:&quot;normal&quot;,&quot;notice_dismissed&quot;:false,&quot;notice_dismissed_update-cf7-5.9.8&quot;:true,&quot;notice_dismissed_update-cf7-6.1.1&quot;:true}}\" \/>\n<\/fieldset>\n<p><span class=\"wpcf7-form-control-wrap\" data-name=\"full_name\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-text wpcf7-validates-as-required\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Name\" value=\"\" type=\"text\" name=\"full_name\" \/><\/span><br \/>\n<span class=\"wpcf7-form-control-wrap\" data-name=\"phone\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-tel wpcf7-validates-as-required wpcf7-text wpcf7-validates-as-tel\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Phone\" value=\"\" type=\"tel\" name=\"phone\" \/><\/span><br \/>\n<span class=\"wpcf7-form-control-wrap\" data-name=\"email_id\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-email wpcf7-text wpcf7-validates-as-email\" aria-invalid=\"false\" placeholder=\"Email\" value=\"\" type=\"email\" name=\"email_id\" \/><\/span>\n<\/p>\n<div class=\"custom-form-group-1\">\n\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"language\"><select class=\"wpcf7-form-control wpcf7-select wpcf7-validates-as-required language-select1\" aria-required=\"true\" aria-invalid=\"false\" name=\"language\"><option value=\"\">Select Language<\/option><option value=\"Malayalam\">Malayalam<\/option><option value=\"Tamil\">Tamil<\/option><option value=\"Telugu\">Telugu<\/option><option value=\"Kannada\">Kannada<\/option><\/select><\/span>\n\t<\/p>\n<\/div>\n<div class=\"custom-form-group-1\">\n\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"course\"><select class=\"wpcf7-form-control wpcf7-select wpcf7-validates-as-required course-select1\" aria-required=\"true\" aria-invalid=\"false\" name=\"course\"><option value=\"\">Select an option<\/option><option value=\"Kerala PSC Exams\">Kerala PSC Exams<\/option><option value=\"Kerala PSC Teaching Exams\">Kerala PSC Teaching Exams<\/option><option value=\"Kerala PSC Technical Exams\">Kerala PSC Technical Exams<\/option><option value=\"SSC\/RRB\">SSC\/RRB<\/option><option value=\"GATE\">GATE<\/option><option value=\"Banking &amp; Insurance\">Banking &amp; Insurance<\/option><option value=\"Coding\">Coding<\/option><option value=\"Commerce\">Commerce<\/option><option value=\"Personal Finance\">Personal Finance<\/option><option value=\"Spoken English\/Personality Dev\">Spoken English\/Personality Dev<\/option><option value=\"German Language\">German Language<\/option><option value=\"Montessori Teacher Training\">Montessori Teacher Training<\/option><option value=\"IELTS\">IELTS<\/option><option value=\"MEP\">MEP<\/option><option value=\"Quantity Surveying\">Quantity Surveying<\/option><option value=\"Structural Design\">Structural Design<\/option><option value=\"Yoga TTC\">Yoga TTC<\/option><option value=\"Digital Marketing\">Digital Marketing<\/option><option value=\"Hospital and Healthcare Administration\">Hospital and Healthcare Administration<\/option><option value=\"BIM\">BIM<\/option><option value=\"HR Management\">HR Management<\/option><option value=\"Embedded System Software Engineering\">Embedded System Software Engineering<\/option><\/select><\/span>\n\t<\/p>\n<\/div>\n<div class=\"custom-form-group-1\">\n\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"course_name\"><select class=\"wpcf7-form-control wpcf7-select wpcf7-validates-as-required course-name-select1\" aria-required=\"true\" aria-invalid=\"false\" name=\"course_name\"><option value=\"\">Select an option<\/option><option value=\"KAS\">KAS<\/option><option value=\"Degree level\">Degree level<\/option><option value=\"12th level\">12th level<\/option><option value=\"10th level\">10th level<\/option><option value=\"Secretariat Assistant\">Secretariat Assistant<\/option><option value=\"LDC\">LDC<\/option><option value=\"LGS\">LGS<\/option><option value=\"University Assistant\">University Assistant<\/option><option value=\"FSO\">FSO<\/option><option value=\"VEO\">VEO<\/option><option value=\"VFA\">VFA<\/option><option value=\"Dental Surgeon\">Dental Surgeon<\/option><option value=\"Staff Nurse\">Staff Nurse<\/option><option value=\"Sub Inspector\">Sub Inspector<\/option><option value=\"Divisional Accountant\">Divisional Accountant<\/option><option value=\"Fireman\/Firewomen\/Driver\">Fireman\/Firewomen\/Driver<\/option><option value=\"CPO\/WCPO\/Driver\">CPO\/WCPO\/Driver<\/option><option value=\"Excise\">Excise<\/option><option value=\"LD Typist\">LD Typist<\/option><option value=\"Junior Health Inspector\">Junior Health Inspector<\/option><option value=\"Assistant Jailor\">Assistant Jailor<\/option><option value=\"Kerala High Court Assistant\">Kerala High Court Assistant<\/option><option value=\"Beat Forest Officer\">Beat Forest Officer<\/option><option value=\"Junior Employment Officer\">Junior Employment Officer<\/option><option value=\"Junior Lab Assistant\">Junior Lab Assistant<\/option><option value=\"Dewaswom Board LDC\">Dewaswom Board LDC<\/option><option value=\"LSGS\">LSGS<\/option><option value=\"SBCID\">SBCID<\/option><option value=\"IRB Regular wing\">IRB Regular wing<\/option><option value=\"Assistant Salesman\">Assistant Salesman<\/option><option value=\"Secretariat OA\">Secretariat OA<\/option><option value=\"Driver Cum OA\">Driver Cum OA<\/option><option value=\"Departmental Test\">Departmental Test<\/option><option value=\"HSST\">HSST<\/option><option value=\"HSA\">HSA<\/option><option value=\"SET\">SET<\/option><option value=\"KTET\">KTET<\/option><option value=\"LP UP\">LP UP<\/option><option value=\"KVS\">KVS<\/option><option value=\"Finger Print Searcher\">Finger Print Searcher<\/option><option value=\"Nursery School Teacher\">Nursery School Teacher<\/option><option value=\"Railway Teacher\">Railway Teacher<\/option><option value=\"Scientific Officer\">Scientific Officer<\/option><option value=\"Probation Officer\">Probation Officer<\/option><option value=\"ICDS\">ICDS<\/option><option value=\"Welfare Officer Gr. II\">Welfare Officer Gr. II<\/option><option value=\"Assistant Professor\">Assistant Professor<\/option><option value=\"CTET\">CTET<\/option><option value=\"UGC NET\">UGC NET<\/option><option value=\"Sanitary Chemist\">Sanitary Chemist<\/option><option value=\"AE\">AE<\/option><option value=\"IEO\">IEO<\/option><option value=\"Electrician\">Electrician<\/option><option value=\"KSEB AE\/Sub Engineer\">KSEB AE\/Sub Engineer<\/option><option value=\"Kerala Agro Industries AE\">Kerala Agro Industries AE<\/option><option value=\"Overseer\/Draftsman\">Overseer\/Draftsman<\/option><option value=\"Lecturer in Polytechnic\">Lecturer in Polytechnic<\/option><option value=\"LSGD AE\">LSGD AE<\/option><option value=\"Devaswom Work Superintendent\">Devaswom Work Superintendent<\/option><option value=\"Devaswom Board Lineman\">Devaswom Board Lineman<\/option><option value=\"Devaswom Board Plumber\">Devaswom Board Plumber<\/option><option value=\"Assistant Town Planner\">Assistant Town Planner<\/option><option value=\"AAI ATC\">AAI ATC<\/option><option value=\"Central Govt PSU\">Central Govt PSU<\/option><option value=\"RRB ALP\">RRB ALP<\/option><option value=\"RRB JE\">RRB JE<\/option><option value=\"GATE\">GATE<\/option><option value=\"Skilled Assistant\">Skilled Assistant<\/option><option value=\"Workshop Instructor\">Workshop Instructor<\/option><option value=\"AMVI\">AMVI<\/option><option value=\"Technician gr 1\">Technician gr 1<\/option><option value=\"Technician gr 3\">Technician gr 3<\/option><option value=\"Assistant Professor - Tech\">Assistant Professor - Tech<\/option><option value=\"KSEB Worker\">KSEB Worker<\/option><option value=\"SSC CGL\">SSC CGL<\/option><option value=\"SSC CHSL\">SSC CHSL<\/option><option value=\"SSC CPO\">SSC CPO<\/option><option value=\"SSC MTS\">SSC MTS<\/option><option value=\"SSC GD Constable\">SSC GD Constable<\/option><option value=\"SSC JE\">SSC JE<\/option><option value=\"SSC Stenographer\">SSC Stenographer<\/option><option value=\"SSC JHT\">SSC JHT<\/option><option value=\"SSC Selection Post\">SSC Selection Post<\/option><option value=\"SSC Scientific Assistant IMD\">SSC Scientific Assistant IMD<\/option><option value=\"SSC Phase IX\/XI Selection Posts\">SSC Phase IX\/XI Selection Posts<\/option><option value=\"RRB NTPC\">RRB NTPC<\/option><option value=\"RRB Group D\">RRB Group D<\/option><option value=\"RRB Paramedical\">RRB Paramedical<\/option><option value=\"RRB Ministerial and Isolated Categories\">RRB Ministerial and Isolated Categories<\/option><option value=\"RRB RPF\">RRB RPF<\/option><option value=\"IBPS PO\">IBPS PO<\/option><option value=\"IBPS Clerk\">IBPS Clerk<\/option><option value=\"IBPS SO\">IBPS SO<\/option><option value=\"IBPS RRB PO\">IBPS RRB PO<\/option><option value=\"IBPS RRB Clerk\">IBPS RRB Clerk<\/option><option value=\"SBI PO\">SBI PO<\/option><option value=\"SBI Clerk\">SBI Clerk<\/option><option value=\"SBI SO\">SBI SO<\/option><option value=\"RBI Grade B\">RBI Grade B<\/option><option value=\"RBI Assistant\">RBI Assistant<\/option><option value=\"NABARD Grade A\">NABARD Grade A<\/option><option value=\"NABARD Grade B\">NABARD Grade B<\/option><option value=\"SIDBI Grade A\">SIDBI Grade A<\/option><option value=\"Insurance Exams\">Insurance Exams<\/option><option value=\"Federal Bank Exams\">Federal Bank Exams<\/option><option value=\"Union Bank of India Exams\">Union Bank of India Exams<\/option><option value=\"Full Stack Development Course\">Full Stack Development Course<\/option><option value=\"Data Science Course\">Data Science Course<\/option><option value=\"Data Analytics Course\">Data Analytics Course<\/option><option value=\"Software Testing Course\">Software Testing Course<\/option><option value=\"Python Programming Course\">Python Programming Course<\/option><option value=\"UI\/UX\">UI\/UX<\/option><option value=\"AWS Course\">AWS Course<\/option><option value=\"Flutter\">Flutter<\/option><option value=\"Cybersecurity\">Cybersecurity<\/option><option value=\"Practical Accounting Course\">Practical Accounting Course<\/option><option value=\"SAP FICO Course\">SAP FICO Course<\/option><option value=\"SAP MM Course\">SAP MM Course<\/option><option value=\"SAP SD Course\">SAP SD Course<\/option><option value=\"PwC Edge: Strategic Accounting &amp; Finance Programme\">PwC Edge: Strategic Accounting &amp; Finance Programme<\/option><option value=\"ACCA\">ACCA<\/option><option value=\"Tally\">Tally<\/option><option value=\"UAE Accounting\">UAE Accounting<\/option><option value=\"GST\">GST<\/option><option value=\"Stock Market Course\">Stock Market Course<\/option><option value=\"Mutual Funds\">Mutual Funds<\/option><option value=\"Forex Trading\">Forex Trading<\/option><option value=\"Kerala PSC Exams\">Kerala PSC Exams<\/option><option value=\"Kerala PSC Teaching Exams\">Kerala PSC Teaching Exams<\/option><option value=\"Kerala PSC Technical Exams\">Kerala PSC Technical Exams<\/option><option value=\"SSC\/RRB\">SSC\/RRB<\/option><option value=\"GATE\">GATE<\/option><option value=\"Banking &amp; Insurance\">Banking &amp; Insurance<\/option><option value=\"Coding\">Coding<\/option><option value=\"Commerce\">Commerce<\/option><option value=\"Personal Finance\">Personal Finance<\/option><option value=\"Spoken English\/Personality Dev\">Spoken English\/Personality Dev<\/option><option value=\"German Language\">German Language<\/option><option value=\"Montessori Teacher Training\">Montessori Teacher Training<\/option><option value=\"IELTS\">IELTS<\/option><option value=\"MEP\">MEP<\/option><option value=\"Quantity Surveying\">Quantity Surveying<\/option><option value=\"Structural Design\">Structural Design<\/option><option value=\"Yoga TTC\">Yoga TTC<\/option><option value=\"Digital Marketing\">Digital Marketing<\/option><option value=\"Hospital and Healthcare Administration\">Hospital and Healthcare Administration<\/option><option value=\"BIM\">BIM<\/option><option value=\"HR Management\">HR Management<\/option><option value=\"Embedded System Software Engineering\">Embedded System Software Engineering<\/option><\/select><\/span>\n\t<\/p>\n<\/div>\n<p><span class=\"wpcf7-form-control-wrap\" data-name=\"education\"><input size=\"40\" maxlength=\"400\" class=\"wpcf7-form-control wpcf7-text wpcf7-validates-as-required\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Educational qualification\" value=\"\" type=\"text\" name=\"education\" \/><\/span>\n<\/p>\n<div style=\"display:none\">\n<input class=\"wpcf7-form-control wpcf7-hidden utm-source\" value=\"\" type=\"hidden\" name=\"utm_source\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-medium\" value=\"\" type=\"hidden\" name=\"utm_medium\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-campaign\" value=\"\" type=\"hidden\" name=\"utm_campaign\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-content\" value=\"\" type=\"hidden\" name=\"utm_content\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden utm-term\" value=\"\" type=\"hidden\" name=\"utm_term\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden blog-url\" value=\"\" type=\"hidden\" name=\"blog_url\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden post-category-name\" value=\"\" type=\"hidden\" name=\"post_category_name\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden post-author-name\" value=\"\" type=\"hidden\" name=\"post_author_name\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden file-url\" value=\"\" type=\"hidden\" name=\"file_url\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden video-url\" value=\"\" type=\"hidden\" name=\"video_url\" \/>\n<input class=\"wpcf7-form-control wpcf7-hidden courseid\" value=\"\" type=\"hidden\" name=\"course_id\" \/>\n<\/div>\n<div class=\"cf7-cf-turnstile\" style=\"margin-top: 0px; margin-bottom: -15px;\"> <div id=\"cf-turnstile-cf7-1118452405\" class=\"cf-turnstile\" data-sitekey=\"0x4AAAAAABVigxtkiZeGTu5L\" data-theme=\"light\" data-language=\"auto\" data-size=\"normal\" data-retry=\"auto\" data-retry-interval=\"1000\" data-action=\"contact-form-7\" data-appearance=\"always\"><\/div> <script>document.addEventListener(\"DOMContentLoaded\", function() { setTimeout(function(){ var e=document.getElementById(\"cf-turnstile-cf7-1118452405\"); e&&!e.innerHTML.trim()&&(turnstile.remove(\"#cf-turnstile-cf7-1118452405\"), turnstile.render(\"#cf-turnstile-cf7-1118452405\", {sitekey:\"0x4AAAAAABVigxtkiZeGTu5L\"})); }, 0); });<\/script> <br class=\"cf-turnstile-br cf-turnstile-br-cf7-1118452405\"> <style>#cf-turnstile-cf7-1118452405 { margin-left: -15px; }<\/style> <script>document.addEventListener(\"DOMContentLoaded\",function(){document.querySelectorAll('.wpcf7-form').forEach(function(e){e.addEventListener('submit',function(){if(document.getElementById('cf-turnstile-cf7-1118452405')){setTimeout(function(){turnstile.reset('#cf-turnstile-cf7-1118452405');},1000)}})})});<\/script> <\/div><br\/><input class=\"wpcf7-form-control wpcf7-submit has-spinner\" type=\"submit\" value=\"Submit\" \/>\n<\/p><div class=\"wpcf7-response-output\" aria-hidden=\"true\"><\/div>\n<\/form>\n<\/div>\n\n<\/div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Let\u2019s take a look at how we can combine sets together to see what results we get! We\u2019ll take a look at the three-set operations that allow us to put sets together \u2013 python set union, intersection, and difference \u2013 and we\u2019ll even see what kind of results we get when we apply these operations [&hellip;]<\/p>\n","protected":false},"author":93,"featured_media":25533126,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1864,1882,1888,1883,1881],"tags":[],"class_list":["post-25533125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-data-science-ml","category-java-programming","category-python-programming","category-react-native","category-web-android-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Set Operations: Union, Intersection, and Difference<\/title>\n<meta name=\"description\" content=\"This guide will cover all three set operations (union and intersection, and difference) and will provide examples to get you started using them in your own projects.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Set Operations: Union, Intersection, and Difference\" \/>\n<meta property=\"og:description\" content=\"This guide will cover all three set operations (union and intersection, and difference) and will provide examples to get you started using them in your own projects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-12T14:30:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-05-18T10:44:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Akhil M G\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Akhil M G\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/\"},\"author\":{\"name\":\"Akhil M G\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6\"},\"headline\":\"Python Set Operations: Union, Intersection, and Difference\",\"datePublished\":\"2022-07-12T14:30:28+00:00\",\"dateModified\":\"2023-05-18T10:44:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/\"},\"wordCount\":2217,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png\",\"articleSection\":[\"Articles\",\"Data Science and Machine Learning\",\"Java Programming\",\"Python Programming\",\"React Native\",\"Web and Android Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/\",\"url\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/\",\"name\":\"Python Set Operations: Union, Intersection, and Difference\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png\",\"datePublished\":\"2022-07-12T14:30:28+00:00\",\"dateModified\":\"2023-05-18T10:44:15+00:00\",\"description\":\"This guide will cover all three set operations (union and intersection, and difference) and will provide examples to get you started using them in your own projects.\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png\",\"width\":820,\"height\":615,\"caption\":\"Python Set Operations: Union, Intersection, and Difference\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/python-programming\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Set Operations: Union, Intersection, and Difference\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6\",\"name\":\"Akhil M G\",\"url\":\"https:\/\/entri.app\/blog\/author\/akhil\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Set Operations: Union, Intersection, and Difference","description":"This guide will cover all three set operations (union and intersection, and difference) and will provide examples to get you started using them in your own projects.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/","og_locale":"en_US","og_type":"article","og_title":"Python Set Operations: Union, Intersection, and Difference","og_description":"This guide will cover all three set operations (union and intersection, and difference) and will provide examples to get you started using them in your own projects.","og_url":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-07-12T14:30:28+00:00","article_modified_time":"2023-05-18T10:44:15+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png","type":"image\/png"}],"author":"Akhil M G","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Akhil M G","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/"},"author":{"name":"Akhil M G","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6"},"headline":"Python Set Operations: Union, Intersection, and Difference","datePublished":"2022-07-12T14:30:28+00:00","dateModified":"2023-05-18T10:44:15+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/"},"wordCount":2217,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png","articleSection":["Articles","Data Science and Machine Learning","Java Programming","Python Programming","React Native","Web and Android Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/","url":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/","name":"Python Set Operations: Union, Intersection, and Difference","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png","datePublished":"2022-07-12T14:30:28+00:00","dateModified":"2023-05-18T10:44:15+00:00","description":"This guide will cover all three set operations (union and intersection, and difference) and will provide examples to get you started using them in your own projects.","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/07\/Untitled-92-1.png","width":820,"height":615,"caption":"Python Set Operations: Union, Intersection, and Difference"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/python-set-operations-union-intersection-and-difference\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Programming","item":"https:\/\/entri.app\/blog\/category\/python-programming\/"},{"@type":"ListItem","position":3,"name":"Python Set Operations: Union, Intersection, and Difference"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6","name":"Akhil M G","url":"https:\/\/entri.app\/blog\/author\/akhil\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25533125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/93"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25533125"}],"version-history":[{"count":9,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25533125\/revisions"}],"predecessor-version":[{"id":25560355,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25533125\/revisions\/25560355"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25533126"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25533125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25533125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25533125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}