Тёмный
No video :(

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

Corey Schafer
Подписаться 1,4 млн
Просмотров 142 тыс.
50% 1

In this Python Programming Tutorial, we will be looking at the Set data structure in-depth and discovering how it can help us solve some common problems. The set can not only solve certain problems more quickly but is also more efficient in many cases. Let's get started...
The code from this video can be found at:
github.com/Cor...
✅ Support My Channel Through Patreon:
/ coreyms
✅ Become a Channel Member:
/ @coreyms
✅ One-Time Contribution Through PayPal:
goo.gl/649HFY
✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot
✅ Corey's Public Amazon Wishlist
a.co/inIyro1
✅ Equipment I Use and Books I Recommend:
www.amazon.com...
▶️ You Can Find Me On:
My Website - coreyms.com/
My Second Channel - / coreymschafer
Facebook - / coreymschafer
Twitter - / coreymschafer
Instagram - / coreymschafer
#Python

Опубликовано:

 

17 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 172   
@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?
@helantopia
@helantopia 5 лет назад
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 5 лет назад
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
@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
@sajnashetty8970
@sajnashetty8970 6 лет назад
Don't get sleep while watching Corey Videos :)I love his Voice.
@jamesbrown6591
@jamesbrown6591 5 лет назад
Your python channel is the best i've found for self-learning, thank you!
@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.
@DongWonHanDWONH
@DongWonHanDWONH 5 лет назад
I never have wrote any comment in RU-vid 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
@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
@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
@deviwadala
@deviwadala 5 лет назад
You are straight from heaven , free lessons and so informative , thank you !!!!
@Ram-bt6yt
@Ram-bt6yt 3 года назад
Thank you very much! I was waiting for the last 1 min. Time complexity part! Sets are really powerful!
@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.
@opalprestonshirley1700
@opalprestonshirley1700 4 года назад
Another great video. I not an expert but I am learning from your vids. Thanks.
@fahimahmed3732
@fahimahmed3732 3 года назад
such an underrated channel
@BrendanMetcalfe
@BrendanMetcalfe 4 года назад
The intersection stuff was interesting. Thanks!
@javiers2133
@javiers2133 6 лет назад
You're the best, the day I can make some money scripting, no doubt I'm going to pay you!!!!
@xainch2360
@xainch2360 5 лет назад
Best instructor ever!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! :)
@abhisheksharma-ib5vw
@abhisheksharma-ib5vw 6 лет назад
You are the best among best...
@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
@Pulsar77
@Pulsar77 5 лет назад
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())
@nunya_bizness24
@nunya_bizness24 2 года назад
Pretty sure I'm gonna give this man a shoutout when I graduate
@Suwarrr
@Suwarrr 6 лет назад
You're the best,Corey Shafer!Awesome video!
@soumyazyx
@soumyazyx 4 года назад
Hello. Request you to prepare a python tutorial on "co-routines". That will be great in clearing some air around the otherwise confusing topic.
@anorderedhole2197
@anorderedhole2197 5 лет назад
This solved a problem in a major way. Thanks.
@MUZIXABA
@MUZIXABA 6 лет назад
Another great tutorial from Mr Schafer.
@guilhermehx7159
@guilhermehx7159 6 лет назад
Your videos are very helpful Corey, thanks!
@dhaval1489
@dhaval1489 5 лет назад
Combining Set with SQLlite3 can give huge comfort level in writing code and getting macro level data easy
@DarkToLight88_
@DarkToLight88_ Год назад
Your channel will help me pass my class. Thank you Sir!
@aditipatil7377
@aditipatil7377 4 года назад
Awesome. To the point and neatly explained. Great job !
@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
@pavelivakin8177
@pavelivakin8177 6 лет назад
Thank you! Awesome work. You motivate me to refactor my «membership test» stuff :)
@jyothi26rab
@jyothi26rab Год назад
Thank you sir ur class was very clear and easy to understand, honestly thank u for making this vedio god bless
@soumyazyx
@soumyazyx 4 года назад
Thank you for your time and effort. Keep spreading the knowledge.
@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)
@victornikolov537
@victornikolov537 6 лет назад
I love to watch your videos, Corey. Keep going! You're the best I know. Pyramid stuff soon? :)
@matanerez8221
@matanerez8221 5 лет назад
Great video! love the simple examples and the detailed explanations. Well Done!
@mdsharukkabirsazib1965
@mdsharukkabirsazib1965 5 месяцев назад
simple and best to understand thanks.
@mohammadakhtar9792
@mohammadakhtar9792 6 лет назад
As always great video Corey!
@narasimharajuballapura1
@narasimharajuballapura1 4 года назад
just watched this video and subscribed : )
@hubertcombomarketing2693
@hubertcombomarketing2693 4 года назад
Great Python Sets Tutorial. Thank You.
@shazkingdom1702
@shazkingdom1702 5 лет назад
This is good for observing patterns... i 🤔 ..... best Channel!
@PaulSmith-zs5je
@PaulSmith-zs5je 6 лет назад
Who learnt something new? Great video
@MrGamit1209
@MrGamit1209 4 года назад
Very good video. Thanks
@DebojitBhadra
@DebojitBhadra 6 лет назад
As always your tutorials are best
@thebuggser2752
@thebuggser2752 2 года назад
Another great video! Might want to mention set equality.
@ahmedjumaah9727
@ahmedjumaah9727 4 года назад
Thanks for the good content Corey, helping a lot. Would be very helpful to prepare some videos about common algorithms for coding interview questions.
@barbarairena6714
@barbarairena6714 6 лет назад
can so give me an practical example of how to use O(n) and O(1) ? thanx
@nikhileshsaggere
@nikhileshsaggere 3 года назад
Excellent tutorial
@thengakola6217
@thengakola6217 4 года назад
I didnt know this duplicating method......thanks
@AdamSmith-ux5if
@AdamSmith-ux5if 6 лет назад
Hi Corey! You’re fckn awesome man! Thanks for the videos!
@coreyms
@coreyms 6 лет назад
Thanks!
@henryyao4860
@henryyao4860 4 года назад
Thank you!
@dishydez
@dishydez 3 года назад
This was great! Thanks!
@thattoofunny
@thattoofunny 6 лет назад
You're the best... Keep it coming....
@unrapidist84
@unrapidist84 5 лет назад
when you write 6.7,8 (min3:31) you insert a space for all of the with one command. how can I do that?
@coreyms
@coreyms 5 лет назад
I am using an auto-linter within Sublime Text. If you watch my video on setting up a Python development environment in Sublime Text then I show how to do this in that video.
@abhisheksharma-ib5vw
@abhisheksharma-ib5vw 6 лет назад
Ultimate ....keep up the good work
@ivanniku2204
@ivanniku2204 4 года назад
Really usefull bro thanks
@Happymoon789
@Happymoon789 5 лет назад
Thanks, a clear instruction on set👍
@trava4156
@trava4156 4 года назад
This is awesome! Thank you
@Mikey-nh9jf
@Mikey-nh9jf 6 лет назад
Great stuff man!
@coreyms
@coreyms 6 лет назад
Thanks!
@raraju789
@raraju789 6 лет назад
Please do a video on multiprocess
@tranthanhbao9978
@tranthanhbao9978 5 лет назад
Great video !!
@user-pt4vn5hr2z
@user-pt4vn5hr2z 5 лет назад
Corey thank you!.
@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.
@orkhanahmadov9963
@orkhanahmadov9963 3 года назад
very informative video thank you so much
@akhilpadmanaban3242
@akhilpadmanaban3242 2 года назад
Hey, what is the time complexity of list(set(l1) ),,...Is that O(n)
@smoothbeak
@smoothbeak 3 года назад
Great info!
@frankliva7438
@frankliva7438 3 года назад
thanks so much buddy!!! it really helped
@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
@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?
@sumanmondal8836
@sumanmondal8836 3 года назад
Thank You!
@ashok9588
@ashok9588 4 года назад
best ever
@pakapeta7772
@pakapeta7772 2 года назад
Thanks man!
@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"
@jagmeetsond6075
@jagmeetsond6075 3 года назад
please keep up the good work, thanks a lot!
@bingolio
@bingolio 2 года назад
Excellent, thx.
@akshadrathod9203
@akshadrathod9203 2 года назад
nicely explain!!
@monzuruljhoney001
@monzuruljhoney001 4 года назад
Why does SET take O(1) ? Is it usung Hash Algorithm or some others?
@matrix26uk
@matrix26uk 5 лет назад
What if the data I need is contained on 2 separate files, how would I use sets to get that data, compare both files and remove any duplicates?
@nesrineb21
@nesrineb21 3 месяца назад
excellent !!!
@mihaiconstantin6815
@mihaiconstantin6815 4 года назад
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 2 года назад
the return output from sets are not in any specific order
@sfr36
@sfr36 Год назад
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
@MouhamedSourangProfile
@MouhamedSourangProfile 3 года назад
Amazing!!
@foreversleepy4379
@foreversleepy4379 2 года назад
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?
@annakh9543
@annakh9543 5 лет назад
thank you, very good explanation :)
@convolucion1981
@convolucion1981 4 года назад
Great!
@jessicabrown1987
@jessicabrown1987 4 года назад
Thank you so much for these
@rimmagizzatova9364
@rimmagizzatova9364 2 года назад
Thanks a lot!
@aev6075
@aev6075 Год назад
So why ever use remove instead of discard unless you want to catch that error and do something with that?
@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.
@KlinikXOfficial
@KlinikXOfficial 4 года назад
would of been awesome if you added union method in there.
@lephucnguyen8750
@lephucnguyen8750 5 лет назад
Thank you so much, this video is very helpful!
@ramanak2213
@ramanak2213 4 года назад
Thank u
@subashchandrapakhrin3537
@subashchandrapakhrin3537 3 года назад
Good One
@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
@DevastaingDj
@DevastaingDj 5 лет назад
Thank you so much!
@anchorman45
@anchorman45 6 лет назад
Could you please explain why searching a set is O(1)?
@doreldaianu4627
@doreldaianu4627 4 года назад
Because sets have no duplicates.
@sagarmehta3515
@sagarmehta3515 6 лет назад
Hi Corey, could you please add some tutorials on the magic methods ( setattr, getattr, setattribute, getattribute )
@danabol9887
@danabol9887 Год назад
how to unpack the set?
@easydatascience2508
@easydatascience2508 Год назад
You can see mine too. They python and R playlists provide most of the fundamentals, with ppt and coding window. Source files can be downloaded from links in description of the video.
@owen7081
@owen7081 4 года назад
Your awesome, this helped a lot.
@SRAVANAM_KEERTHANAM_SMARANAM
@SRAVANAM_KEERTHANAM_SMARANAM 5 лет назад
Sir, Union or | are both the same. then why is the code below giving error s=set([1, 2, 3]) s.union([4, 5]) # No error for this line s|([4, 5]) # error for this line
@jl1267
@jl1267 5 лет назад
The vertical bar is the "BINARY OR" operator. It is not the same as the union function of the set class.
Далее
Python lists, sets, and tuples explained 🍍
15:06
Просмотров 258 тыс.
5 Good Python Habits
17:35
Просмотров 491 тыс.
Compiled Python is FAST
12:57
Просмотров 106 тыс.
This Is Why Python Data Classes Are Awesome
22:19
Просмотров 800 тыс.
Please Master These 10 Python Functions…
22:17
Просмотров 130 тыс.
25 nooby Python habits you need to ditch
9:12
Просмотров 1,7 млн
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
10 Python Comprehensions You SHOULD Be Using
21:35
Просмотров 139 тыс.
These Illusions Fool Almost Everyone
24:55
Просмотров 2,2 млн
Modern Python logging
21:32
Просмотров 176 тыс.
11 Tips And Tricks To Write Better Python Code
11:00
Просмотров 609 тыс.