Python Tutorial: Sets - Set Methods and Operations to Solve Common Problems

  Рет қаралды 145,668

Corey Schafer

Corey Schafer

Күн бұрын

Пікірлер: 174
@coreyms
@coreyms 6 жыл бұрын
A couple of times in the video I said "set function" when I really should have said "set class". FYI
@vinodkumar-zf6vk
@vinodkumar-zf6vk 6 жыл бұрын
Thats Totally Okay . your video is awesome
@jasonjluo
@jasonjluo 6 жыл бұрын
can you please do an oauth2 tutorial?
@timoissakainen5157
@timoissakainen5157 2 ай бұрын
7:03 7:05 ​@jasonjl 8:00 😅😊😊 9:26 😅uo
@deojeetsarkar2006
@deojeetsarkar2006 5 жыл бұрын
I failed to search for a solution online to a question, it was nowhere but here. He is the master-answer to Python.
@helantopia
@helantopia 6 жыл бұрын
Thank you so much for making these videos Corey! I discovered your videos after failing my exam on Python and with just a week of watching your videos I passed the retake exam with a 1,7 !!! 😍 I honestly can't thank you enough, I also really enjoy programming now :)
@coreyms
@coreyms 6 жыл бұрын
That's awesome! Congrats on your test scores! Glad to hear you're finding it more enjoyable now. It definitely takes time, but if you stick with it then it becomes very fulfilling. Best of luck!
@randomthingz9631
@randomthingz9631 Жыл бұрын
dumb shit
@TaimTeravel
@TaimTeravel 2 ай бұрын
​@@coreyms This video might be old but it's still gold. Thank you Corey. You made learning easier.
@sajnashetty8970
@sajnashetty8970 6 жыл бұрын
Don't get sleep while watching Corey Videos :)I love his Voice.
@alexmomotov792
@alexmomotov792 6 жыл бұрын
Yaaay! First video in a while! Hope you keep making them Corey, you are the best Python teacher ever.
@coreyms
@coreyms 6 жыл бұрын
Thanks. I’m going to try to get on a schedule of releasing almost every week, but it is difficult when also working on larger courses. But I will try. We’ll see how it goes.
@aloksingh422
@aloksingh422 6 жыл бұрын
You are super sir ..🙏🏻 keep going
@jamesbrown6591
@jamesbrown6591 5 жыл бұрын
Your python channel is the best i've found for self-learning, thank you!
@DongWonHanDWONH
@DongWonHanDWONH 5 жыл бұрын
I never have wrote any comment in KZbin video until now, but I got to say your videos are really awesome! Great help to me. Thank you!!
@coreyms
@coreyms 5 жыл бұрын
Thanks!
@brotherlui5956
@brotherlui5956 6 жыл бұрын
Wasn't interested in sets so far but now i know how to handle them
@deviwadala
@deviwadala 5 жыл бұрын
You are straight from heaven , free lessons and so informative , thank you !!!!
@Chris_87BC
@Chris_87BC 2 жыл бұрын
Great presentation, Corey! I recently used set(a1) - set(a2) to find claims in set a1 not in set a2 :) I am starting to like sets as the calculation was done super-fast. List comparison was very slow
@opalprestonshirley1700
@opalprestonshirley1700 5 жыл бұрын
Another great video. I not an expert but I am learning from your vids. Thanks.
@Pulsar77
@Pulsar77 6 жыл бұрын
An important caveat is that sets don't preserve order. So the elements of newlist = list(set(oldlist)) can end up in a different order than in oldlist. If you want to remove duplicates from a list while preserving order, use an OrderedDict: newlist = list(OrderedDict.fromkeys(oldlist).keys()) In Python 3.6 or later, you can simply use dict: newlist = list(dict.fromkeys(oldlist).keys())
@Ram-bt6yt
@Ram-bt6yt 4 жыл бұрын
Thank you very much! I was waiting for the last 1 min. Time complexity part! Sets are really powerful!
@utkarshgautam1940
@utkarshgautam1940 3 жыл бұрын
ohh my god ,man i never seen anyone who teaches soo good,this guy here is awesome,im from india watching and learning from ur nice stufff man,u totally nailed it
@Arrowtake
@Arrowtake 5 жыл бұрын
Thank you Corey for your great videos. You have made so many exellent videos that are such a treasure for learning python.
@xainch2360
@xainch2360 5 жыл бұрын
Best instructor ever!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)
@javiers2133
@javiers2133 6 жыл бұрын
You're the best, the day I can make some money scripting, no doubt I'm going to pay you!!!!
@soumyazyx
@soumyazyx 5 жыл бұрын
Hello. Request you to prepare a python tutorial on "co-routines". That will be great in clearing some air around the otherwise confusing topic.
@DarkToLight88_
@DarkToLight88_ Жыл бұрын
Your channel will help me pass my class. Thank you Sir!
@fahimahmed3732
@fahimahmed3732 3 жыл бұрын
such an underrated channel
@Suwarrr
@Suwarrr 6 жыл бұрын
You're the best,Corey Shafer!Awesome video!
@adesuwabeckyporter3640
@adesuwabeckyporter3640 3 жыл бұрын
I love your collection of books in your wishlist and your clear interest in exploring the conscious mind. I imagine it'd be so fun to go deep with you on the topic, exploring our thoughts both in "conscious" and "altered" state, documenting our perception of both states. lol.. yes I could have said that in fewer words but.. lol.. recruiter lurkers happen.. lol
@noobinvestor3180
@noobinvestor3180 6 жыл бұрын
Hi Corey..love all your videos...No one better imo...Maybe you can add also why it takes only O(1) for a set and why we should use set while searching if order of the items is not an issue --- My personal suggestion
@coreyms
@coreyms 6 жыл бұрын
I thought about adding more details but didn't want to make it too confusing. I probably should've provided additional material for those who are interested though. Here is further reading on how sets are implemented and why they are accessed in constant time... stackoverflow.com/questions/3949310/how-is-set-implemented
@willofirony
@willofirony 6 жыл бұрын
At the risk of being pedantic, isn't the search operation of a random list O(n/2)? One ceases to search after finding. If the list is sorted, searching would be O(log n) worst case when using a Binary Search..
@noobinvestor3180
@noobinvestor3180 6 жыл бұрын
Hi Michael, searching a element at either end of the list will give O(1) time complexity, whereas for elements within the list will have O(n) time, by using binary search in a sorted list, yes the search time will be O(logn)
@jyothi26rab
@jyothi26rab 2 жыл бұрын
Thank you sir ur class was very clear and easy to understand, honestly thank u for making this vedio god bless
@anorderedhole2197
@anorderedhole2197 5 жыл бұрын
This solved a problem in a major way. Thanks.
@abhisheksharma-ib5vw
@abhisheksharma-ib5vw 6 жыл бұрын
You are the best among best...
@soumyazyx
@soumyazyx 5 жыл бұрын
Thank you for your time and effort. Keep spreading the knowledge.
@nunya_bizness24
@nunya_bizness24 2 жыл бұрын
Pretty sure I'm gonna give this man a shoutout when I graduate
@BrendanMetcalfe
@BrendanMetcalfe 4 жыл бұрын
The intersection stuff was interesting. Thanks!
@mdsharukkabirsazib
@mdsharukkabirsazib 8 ай бұрын
simple and best to understand thanks.
@hubertcombomarketing2693
@hubertcombomarketing2693 4 жыл бұрын
Great Python Sets Tutorial. Thank You.
@MUZIXABA
@MUZIXABA 6 жыл бұрын
Another great tutorial from Mr Schafer.
@shazkingdom1702
@shazkingdom1702 5 жыл бұрын
This is good for observing patterns... i 🤔 ..... best Channel!
@aditipatil7377
@aditipatil7377 4 жыл бұрын
Awesome. To the point and neatly explained. Great job !
@pavelivakin8177
@pavelivakin8177 6 жыл бұрын
Thank you! Awesome work. You motivate me to refactor my «membership test» stuff :)
@guilhermehx7159
@guilhermehx7159 6 жыл бұрын
Your videos are very helpful Corey, thanks!
@PaulSmith-zs5je
@PaulSmith-zs5je 6 жыл бұрын
Who learnt something new? Great video
@thebuggser2752
@thebuggser2752 3 жыл бұрын
Another great video! Might want to mention set equality.
@matanerez8221
@matanerez8221 5 жыл бұрын
Great video! love the simple examples and the detailed explanations. Well Done!
@DebojitBhadra
@DebojitBhadra 6 жыл бұрын
As always your tutorials are best
@nomanabid7113
@nomanabid7113 5 жыл бұрын
16:13 shame on those two for not having awesome job or staying in shape xDDDDD
@borninthedark7915
@borninthedark7915 4 жыл бұрын
I lol'd.
@1polyron1
@1polyron1 3 жыл бұрын
@@borninthedark7915 I combusted
@mohammadakhtar9792
@mohammadakhtar9792 6 жыл бұрын
As always great video Corey!
@victornikolov537
@victornikolov537 6 жыл бұрын
I love to watch your videos, Corey. Keep going! You're the best I know. Pyramid stuff soon? :)
@MrGamit1209
@MrGamit1209 5 жыл бұрын
Very good video. Thanks
@narasimharajuballapura1
@narasimharajuballapura1 4 жыл бұрын
just watched this video and subscribed : )
@nikhileshsaggere
@nikhileshsaggere 3 жыл бұрын
Excellent tutorial
@thattoofunny
@thattoofunny 6 жыл бұрын
You're the best... Keep it coming....
@ahmedjumaah9727
@ahmedjumaah9727 5 жыл бұрын
Thanks for the good content Corey, helping a lot. Would be very helpful to prepare some videos about common algorithms for coding interview questions.
@Happymoon789
@Happymoon789 6 жыл бұрын
Thanks, a clear instruction on set👍
@rudela9900
@rudela9900 4 жыл бұрын
Would you be so kind as to go over the very basics of neural networks, using very basic number sequences and involving nothing more than numpy, if necessary? Thanks a lot for a great job.
@thengakola6217
@thengakola6217 4 жыл бұрын
I didnt know this duplicating method......thanks
@abhisheksharma-ib5vw
@abhisheksharma-ib5vw 6 жыл бұрын
Ultimate ....keep up the good work
@dishydez
@dishydez 3 жыл бұрын
This was great! Thanks!
@henryyao4860
@henryyao4860 4 жыл бұрын
Thank you!
@trava4156
@trava4156 5 жыл бұрын
This is awesome! Thank you
@orkhanahmadov9963
@orkhanahmadov9963 3 жыл бұрын
very informative video thank you so much
@gianfrancomirto8765
@gianfrancomirto8765 4 жыл бұрын
Perfect Video!!! Just wondering is there any videos you know that look at the underlying code of the methods of add add,discard and such?? Thank you
@ivanniku2204
@ivanniku2204 5 жыл бұрын
Really usefull bro thanks
@frankliva7438
@frankliva7438 3 жыл бұрын
thanks so much buddy!!! it really helped
@AdamSmith-ux5if
@AdamSmith-ux5if 6 жыл бұрын
Hi Corey! You’re fckn awesome man! Thanks for the videos!
@coreyms
@coreyms 6 жыл бұрын
Thanks!
@user-pt4vn5hr2z
@user-pt4vn5hr2z 5 жыл бұрын
Corey thank you!.
@Mikey-nh9jf
@Mikey-nh9jf 6 жыл бұрын
Great stuff man!
@coreyms
@coreyms 6 жыл бұрын
Thanks!
@priyabratasaha4339
@priyabratasaha4339 6 жыл бұрын
Hello Corey, Love your videos. I am currently focusing on metaprogramming in python. Your video on decorator helped a lot. can you suggest some good resources about meta classes and descriptors. Thanks a lot for your effort
@monzuruljhoney001
@monzuruljhoney001 4 жыл бұрын
Why does SET take O(1) ? Is it usung Hash Algorithm or some others?
@jagmeetsond6075
@jagmeetsond6075 3 жыл бұрын
please keep up the good work, thanks a lot!
@tranthanhbao9978
@tranthanhbao9978 6 жыл бұрын
Great video !!
@raraju789
@raraju789 6 жыл бұрын
Please do a video on multiprocess
@klaik30
@klaik30 4 жыл бұрын
One thing I don't really get is how some of these inbuilt functions can be so much faster than any other function you could yourself write. Doesn't the program have to do the same thing but more when I first convert the list into a set then the set into a list again? Doesn't it still have to go through every element and check if it has already saved a certain value? What magic is happening behind the curtains?
@barbarairena6714
@barbarairena6714 6 жыл бұрын
can so give me an practical example of how to use O(n) and O(1) ? thanx
@annakh9543
@annakh9543 5 жыл бұрын
thank you, very good explanation :)
@smoothbeak
@smoothbeak 4 жыл бұрын
Great info!
@lephucnguyen8750
@lephucnguyen8750 5 жыл бұрын
Thank you so much, this video is very helpful!
@jessicabrown1987
@jessicabrown1987 4 жыл бұрын
Thank you so much for these
@KlinikXOfficial
@KlinikXOfficial 4 жыл бұрын
would of been awesome if you added union method in there.
@akshadrathod9203
@akshadrathod9203 3 жыл бұрын
nicely explain!!
@pakapeta7772
@pakapeta7772 2 жыл бұрын
Thanks man!
@ramanak2213
@ramanak2213 4 жыл бұрын
Thank u
@bingolio
@bingolio 2 жыл бұрын
Excellent, thx.
@kiraal3619
@kiraal3619 4 жыл бұрын
for min 7:44, i tried something else which is way complex XDD. but i just would like to share s1={1, 2, 3,4,5,6} s2={5,2,7} s3={1,2,5,7} first_intersection=s1.intersection(s2) ## intersection between S1 and S2 second_intersection=first_intersection.intersection(s3) ## intersection between S1,S2 and S3 print("intersection between S1 and S3",first_intersection) print("intersection between S1,S2 and S3",second_intersection)
@convolucion1981
@convolucion1981 5 жыл бұрын
Great!
@ashok9588
@ashok9588 4 жыл бұрын
best ever
@sagarmehta3515
@sagarmehta3515 6 жыл бұрын
Hi Corey, could you please add some tutorials on the magic methods ( setattr, getattr, setattribute, getattribute )
@nesrineb21
@nesrineb21 6 ай бұрын
excellent !!!
@jasondeb2678
@jasondeb2678 3 жыл бұрын
could you please explain big O' notation in a separate video, that would be very helpful?
@nocturn2002
@nocturn2002 5 жыл бұрын
how can someone dislike the video
@IsaacC20
@IsaacC20 6 жыл бұрын
I'm surprised you didn't cover how to make sets of custom user objects.
@mihaiconstantin6815
@mihaiconstantin6815 5 жыл бұрын
Hey! You're videos are fantastic, but trying some things by my self while watching your video, i've come up with this: ss1 = {1,2,3,4,8,9,11} ss2 = {2,3,4,5} ss3 = {3,4,5,6} ssx = {2,3,5,6} ss5 = ss1.difference(ss2, ss3, ssx) print (ss5) #output -> {8, 1, 11, 9} Please explain me why this order?
@iToastDevice
@iToastDevice 3 жыл бұрын
the return output from sets are not in any specific order
@sfr36
@sfr36 2 жыл бұрын
we use sets where the order is not important. it has random order assigned to it. this is why indexing is also not supported like lists
@owen7081
@owen7081 4 жыл бұрын
Your awesome, this helped a lot.
@MouhamedSourangProfile
@MouhamedSourangProfile 3 жыл бұрын
Amazing!!
@programmer4833
@programmer4833 4 жыл бұрын
I do have a question : I didn't understand the last comment you made about O(n) for lists and O(1) for sets. What does that mean ?
@sebastiancristicastillo479
@sebastiancristicastillo479 4 жыл бұрын
That is a notation that says how much time it will take to complete, depending the size of the operation. being O(n) the time the operation takes to complete increase as the list grow in size, but O(1) is constant and will not be affected by the size of the data set. You can search for more info about it looking for "Big O notation"
@DevastaingDj
@DevastaingDj 6 жыл бұрын
Thank you so much!
@hamzashabbir3589
@hamzashabbir3589 2 жыл бұрын
Why Set has O(1) Complexity? Didn't understand that. Lits is Fine O(n) as it traverses each element to find a value.
@ghanteyyy
@ghanteyyy 6 жыл бұрын
Hi Corey! Thanks for the awesome videos. If you don't mind, I really need your help to learn sending attachments like photos, videos, documents ,etc in email using email module.
@gtg7529
@gtg7529 6 жыл бұрын
Thanks your video! and because your channel does not update more than 1 month, i am very worry about u!
@coreyms
@coreyms 6 жыл бұрын
I’m just working on larger series’. I’m going to try to put out more smaller videos like this once a week while working on larger courses from now on
@subashchandrapakhrin3537
@subashchandrapakhrin3537 3 жыл бұрын
Good One
@expat2010
@expat2010 3 жыл бұрын
IDK about anyone else, but generally I am working with datasets. SO for me, what is missing from this video and many others, is how to use a function like this working with a dataset. For example, how to search a column for a member of a set.
@LearningOrbis
@LearningOrbis 3 жыл бұрын
There is no column for the number in set. There is no order of elements inside the set. You can watch detailed videos on different Data Sets at my Channel :)
@carpediem73
@carpediem73 4 жыл бұрын
thanks
@foreversleepy4379
@foreversleepy4379 3 жыл бұрын
Wouldn't creating a list from a set be O(n) time, though? So while using a set to remove duplicates is better, if you're casting it to a list, would it really make much difference?
@babysuyash
@babysuyash 4 жыл бұрын
Thank you for the great explanation !! I understood everything about sets but I got confused when you did set(gym_members).intersection(developers) in 14:58 ...I was confused whether developers , a list , should be changed into set before intersection..... is developer already changed into the set or intersection is done between list and a set?
@CosmosWorld
@CosmosWorld 4 жыл бұрын
As you see, the program has no problem with that, so i say, that if you intersect a set to a list, it won't produce any problem.
@akhilpadmanaban3242
@akhilpadmanaban3242 2 жыл бұрын
Hey, what is the time complexity of list(set(l1) ),,...Is that O(n)
Python Django Tutorial: Full-Featured Web App Part 1 - Getting Started
15:32
Python lists, sets, and tuples explained 🍍
15:06
Bro Code
Рет қаралды 308 М.
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 31 МЛН
Trapped by the Machine, Saved by Kind Strangers! #shorts
00:21
Fabiosa Best Lifehacks
Рет қаралды 39 МЛН
5 Good Python Habits
17:35
Indently
Рет қаралды 606 М.
5 Signs of an Inexperienced Self-Taught Developer (and how to fix)
8:40
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 814 М.
Python Tutorial: Context Managers - Efficiently Managing Resources
20:37
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 208 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 279 М.
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 413 М.
Python 101: Learn the 5 Must-Know Concepts
20:00
Tech With Tim
Рет қаралды 1,2 МЛН
10 Python Tips and Tricks For Writing Better Code
39:21
Corey Schafer
Рет қаралды 1,3 МЛН
When Cucumbers Meet PVC Pipe The Results Are Wild! 🤭
00:44
Crafty Buddy
Рет қаралды 31 МЛН