In this video the following topics are explained
1. Set creation
unordered collection of data , we cannot use slice operator to access the elements.
1. set() - This set is an inbuilt function that can be used to create a Set , it can take any iterable Like
A LIST
A TUPLE
A RANGE
etc
The example of this is shown in the video
2.literals - This is the most basic and easiest Method to create a set in Python I will provide the Example here itself
consider
numbers = {1, 2, 3, 4}
This creates your sets and Remember that sets do not allow any kind of duplicates in to it.
3. set comprehensions - As i have explained in my List comprehension Video , This set comprehensions are same as well except they contain Curly braces over them
The syntax for the set comprehension is
{var_name for var_name in range(s,e) if condtion(optional)}
The example for this is explained in the video in it's best manner
is expression with a loop and an optional condition
var for var in range(start,end) if....
2. Operations on Sets
1. Union ---- | -- Joins two sets except no duplicates
2. Difference ---- - Removes the common element and take the LEFT SIDE SET ELEMENTS AS THE RESULT
3. Intersection --- & -- Only considers the common values from both the sets
4. Symmetric Difference ---- ^ -- it removes the common elements and Returns the answer of Both the sets , best explanation is given in the video itself
3. Set methods
1.Pop - It removes a random element from the set
2.Remove(x)-- Removes x from the set
3.copy() -- copies the set
4.s.add(x)-- adds an element x to set s
5.Difference --- It is as Same as A-B
6.Union-- it is as Same as AuB
7. Intersection --- it is as Same AnB
8.A.Symmetric Difference(B) -- it is as Same as A^B
9.A.issubset(B) -- it check if the A is a subset of B , if so returns True otherwise returns False
10. A.issuperset(B) --it check if the A is a superset of B , if so returns True otherwise returns False
11.A.isdisjoint(B) --it check if the A is a disjoint of B , if so returns True otherwise returns False
Sets in Python , Set Operations , Methods and Comprehensions - Python Programming part 12
On this page of the site you can watch the video online Sets in Python , Set Operations , Methods and Comprehensions - Python Programming part 12 with a duration of hours minute second in good quality, which was uploaded by the user Learning With Faraz 27 April 2020, share the link with friends and acquaintances, this video has already been watched 129 times on youtube and it was liked by 10 viewers. Enjoy your viewing!