[no audio]
Friends, here we are going to discuss the last
default data structure of your Python,
that is set data structure.
Let me open my terminal,
and I'm entering into 'python' terminal, right. See if you want
to define any set,
let's say 'my_set={' with normal values.
You can define any value, okay.
See that, now I am printing my set.
[no audio]
So the way how you are giving,
, but it is giving output as
in ascending order, that means whatever the data you're providing
it is not giving the same order. That means sets are called
unordered collection of data.
And if you give any data multiple times, if you give data,
duplicates data or multiple times of data, suppose
I have given 7, two times,
so set will give unique data. Duplicates will be removed by
default. That's it.
Now if we convert your data into Boolean, 'True', because it is
non-empty set, right?
Let me define 'my_set' which is having a non empty,
[no audio]
sorry empty set.
So guys if you want to define empty set you have to write
a 'set()', because if you define direct straight
forward curly brace that will become dictionary.
Now print the type of your 'my_set'.
[no audio]
Now let me print Boolean of your 'my_set'. It is 'False' because
empty set, right?
So guys, this is the way how you can define your set,
right, and how you can convert your set into Boolean,
and what is the data you are getting when your set is
empty. Let's say I'm having a list called 'my_list
equals to,
[no audio]
you can convert this list into set, 'set(my_list)'.
[no audio]
That's it. In case you have any data multiple times
in your list your set will give the unique data.
That's it,
and anyway it is ascending order, that means unordered collection
actually, right. Fine.
So if you want to see the different types of operations on
your sets simply you can run this and you can see.
[no audio]
So, or you can do you know, let's say set 'a' is there in this way
, and set 'b' is there in this way .
[no audio]
So I want to find 'a union b', right. 'a.union(b)'.
See the output. 'a.intersection',
[no audio]
'intersection(b)'. That's it.
Okay. So guys there are remaining operations as well,
but on automation side no where we are going to touch this
set data structure.
If you are interested you can go and learn about your remaining
operations on your sets. I've gone through only union, intersection,
if you are interested about sets anyway, your mathematics
sets operation only, right. You can go and see the remaining
operations, okay.
Okay guys, thank you for watching this video.
[no audio]