Skip to playerSkip to main contentSkip to footer
  • 5/18/2025
In Python, a set is a built-in data type used to store an unordered collection of unique elements. Sets are mutable, meaning elements can be added or removed after the set is created. Python also offers frozenset, an immutable version of a set.

Category

📚
Learning
Transcript
00:00Welcome back and good morning.
00:30Welcome back and good morning.
01:00Congratulations.
01:01आपने पहला जो टेस्ट से जो सेट है वो डिफाइन कर लिया.
01:05अब पहली डेफिनेशन यह थी कि यह अन ओर्डर होता है.
01:08इसका मतलब यह है कि अगर मैं इसको कहूं कि यार मुझे जिरोत इंडेक्स के उपर बताओ कौन सा एलिमेंट फड़ा हुआ है.
01:14पढ़ा हुआ है तो यह मुझे एरर देगा कहेगा यह और्डर नहीं है.
01:18आप ऐसे एकसेस नहीं कर सकते है अलिमेंट को.
01:21दूसरी चीज इसकी मैंने यह कही थी कि यह यूनिक आपजेक्ट को ओल्ड करता है.
01:25मतलब यह है कि अगर इसके अंदर मैं एक और फाइव ऐलिमेंट डाल दूँ और इसको प्रिंट कराऊं तो लेट सी अगर हमार पास क्या आता है.
01:32तो क्योंके दो दफाफा फाइव आया यूनिक नहीं रहा तो उसने का नहीं मैं दूसरे डिसकार्ड करने लगा हूं मैं सिर्फ एक फाइव को ओल्ड करूंगा.
01:40This way you will see that you will only have one, two, three, four and five. Nothing else.
01:52This is unique objects.
01:54Okay.
01:56Let's talk about built-in methods.
02:01First of all, add method.
02:03For example, if I test set, underscore set, dot add method call,
02:08and I will say that I will add 100.
02:11If I print it, I will add test set.
02:17I will cut and run.
02:21Now we will see that our previous set was 5,
02:24and this value return.
02:27This method itself is a new method return.
02:33This method will add a new copy value.
02:38For example,
02:41new, underscore set, is equal to test, test, underscore set, dot copy.
02:50So, dot copy basically,
02:52is a method which we call the test set,
02:54which we call the new set.
02:56Okay.
02:57Now, in the new set,
02:58we can call the simple dot add method.
03:02However, again,
03:04because the value value is not returned,
03:07the original value is in change.
03:09So, we will show the value value to the original value.
03:13For example,
03:15I will disengage the copy and test set,
03:18because the change was in change.
03:19So, now I will add the test set.
03:21I will print the test set.
03:22I will print it.
03:23I will print it.
03:24I will print it.
03:26And run it.
03:27You will see that 100 value will be returned.
03:30I will remove it.
03:32Okay.
03:34Because 100 already exists,
03:36it will be added.
03:38Let's see if I can add 5.
03:40Run it.
03:41The 5 cannot be added.
03:42As you can see.
03:43Okay.
03:44Okay.
03:45Okay.
03:46Okay.
03:47Now,
03:48let's see.
03:49Let's see.
03:50Let's see.
03:51Set theory.
03:52Set theory.
03:53For example,
03:54if you have a set A,
03:56and this set B,
03:57what can you do?
03:59What can you do?
04:00Union can do something like that.
04:02Something like that.
04:03Okay.
04:04And two sets can do intersection.
04:06Okay.
04:07And two sets can do difference.
04:10Let's see.
04:11Let's see.
04:12Let's see.
04:13Let's see.
04:14One, two, three.
04:15Just for the sake of simplicity.
04:17So,
04:18we have a test set.
04:19Let's see.
04:20Union.
04:21You can see.
04:22Union.
04:23You can see.
04:24This is a test set.
04:25And one.
04:26We have a test set.
04:27And two.
04:28Use.
04:29Let's see.
04:30And one.
04:31Two.
04:32Three.
04:33Just for the sake of simplicity.
04:35So,
04:36two.
04:37We have a test set.
04:38First,
04:39we can see.
04:40Test.
04:41Underscore.
04:42Set.
04:431.
04:44Union.
04:45Union.
04:46Union.
04:47With test set.
04:482.
04:49Union.
04:50There is a set set.
04:51But,
04:52the common element is redundant.
04:53It is not redundant.
04:54It is not repeated.
04:55For example,
04:56I say,
04:57No.
04:58Just for the sake of simplicity.
05:00Just for the sake of simplicity.
05:01So,
05:02we have a test set.
05:03We have a test set.
05:04I say,
05:05Nine.
05:06Nine.
05:07Nine.
05:08Nine.
05:09Nine.
05:10Nine.
05:11Nine.
05:12Nine.
05:13Nine.
05:14Nine.
05:15Nine.
05:16Nine.
05:17Nine.
05:18Nine.
05:19Nine.
05:20Nine.
05:21Nine.
05:22Nine.
05:23Nine.
05:24Nine.
05:25Nine.
05:26Nine.
05:27Nine.
05:28Nine.
05:29Nine.
05:30Nine.
05:31Nine.
05:32Nine.
05:33Nine.
05:34you see the same result union
05:41this is intersection
05:44union is just join
05:48intersection will return
05:51which are common
05:53intersection
05:55test one test two
05:57as you see
06:00common
06:02nine
06:04let's say
06:05seven
06:06seven
06:07common
06:08now
06:09you will be
06:10common
06:11nine
06:12and seven
06:13basically
06:14if I go back
06:16diagram
06:17this intersection
06:20this region
06:22return
06:23this set
06:24a
06:25this
06:26common values
06:27return
06:28however
06:29union
06:30two set
06:32union
06:33then
06:35this area
06:36return
06:37this
06:38area
06:39return
06:40intersection
06:41uniquely
06:42return
06:43as a single region
06:45return
06:46you understand
06:47intersection
06:48is
06:49this
06:50line
06:51uniquely
06:52set
06:53return
06:54this
06:55is
06:56difference
06:57difference
06:58basically
06:59you can see
07:01intersection
07:02you can see
07:03one
07:04two
07:05three
07:06and
07:07eight
07:08you can see
07:09you can see
07:10one
07:11two
07:12three
07:13one
07:14two
07:15three
07:16and
07:17eight
07:18so
07:19you can see
07:20one
07:21two
07:22three
07:23eight
07:24basically
07:25set
07:26one
07:27two
07:28eight
07:29basically
07:30set
07:31one
07:32exist
07:33set
07:34one
07:35set
07:36two
07:37order
07:38that is
07:39very important
07:40for example
07:41if you
07:42intersection
07:43with
07:44set
07:45two
07:46and set
07:47one
07:48result
07:49will be
07:50different
07:51so
07:52you can see
07:53union
07:54difference
07:55because
07:56if
07:57one
07:58result
07:59will be
08:00different
08:01as you
08:02see
08:03one
08:04two
08:05three
08:06okay
08:07so
08:08congratulations
08:09guys
08:10you have
08:11done
08:12the data
08:13structure
08:14completely
08:15give
08:16yourself
08:17a big
08:18tap
08:19okay
08:20close
08:21and then
08:22we will
08:23start

Recommended