Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Can you believe it.
I hope I didn't put you to sleep but we're almost there.
We have one last main data type set and then we're done.
I know I know this isn't the most exciting topic.
Trust me this is the hardest part when you're starting out and you're just learning these things without
understanding.
Why do I need this.
How am I going to build the next game How am I going to build the next Netflix how we're going to build
the next coolest Apple app.
You're looking at this and thinking I just learned a bunch of theory I feel like I'm in math class all
over again.
I know trust me.
I went through this.
I was a self-taught programmer as well.
These are the Lego blocks that builds our foundation.
Once we learn these we can move on to new things and you'll see that once you climb this little mountain
things become so much easier and you'll realize the power.
When we start building these projects toward the end of the class where you're going to say oh all these
blocks that we learned all this frankly boring part is all going to make sense.
So hang in there.
It's supposed to be hard.
It's supposed to be tough but you'll see very soon why this is so powerful and why what we've just learned
is going to allow us to build some really awesome things and create some really awesome programs.
So let's finish off with the last one.
The last data type the last data structure that we'll see in Python at least from the main ones and
it's called set and sets are simply on ordered collections of unique objects.
Let's have a look.
Let's create a my set and my set.
We create with curly brackets like a dictionary.
But instead of a dictionary we don't have key value pairs.
Instead we just have values like One two three four or five.
That's it.
That's a set we just created a set.
But remember the definition I gave you set is an unordered collection of unique objects.
What does that mean.
Well if I print this and say my set and I click Run I get a set but if I had let's say another five
in here and I click Run it only returns the unique sets or unique items you see in a set.
There's no duplicates.
Everything has to be unique so this fire just never gets added to a set.
For example you can add things to a set like my set and then I can say dot add and give it a value like
100 and then let's say I do my set dot add and then give it to if I click Run here I see that I was
able to add a hundred but two well to wasn't really added because my set already contained that data.
It's on ordered.
I mean we've created one two three four five here but there's no real order to it.
There's no bookshelf in our memory space.
That is right next to each other.
These are all over the place in memory but a set is able to find them because they're all unique.
So they're all in just one location in memory so let me ask you this and this is going to be a fun little
exercise if I gave you an array and let's say this array contained.
Well this right here and I want you to return an array with no duplicates.
So I want everything in let's say let's call it my list and a programmer has already created this OK
and then your task is to create or return a list or a collection that has only unique items.
How would you go about converting this into a set.
Well we've seen this before.
We have a set function and we simply wrap my list in that set and that's printed out i click Run.
Check it out.
We have formed a new set from a list and I've removed all duplicate values.
When would this be useful.
Imagine if we had user names right.
Or email addresses where collecting email addresses on our startup page.
But we don't want to have duplicate emails.
We might want to convert this a list of emails to a set and remove any duplicates so we're not sending
emails over and over.
So that's really cool.
What about this.
Can I.
Let's change this into a set.
So let's call it my set going to change this into a set.
There you go.
And then what if I wanted to access my set at index of 0 set.
Object does not support indexing.
Well again you can think of it more as a dictionary in order to access a set.
We have to grab by the item that's in it.
That's the key to getting the information from memory.
The way we would check if something exists is we simply say hey is one in my set.
And we run this and we get true we can also do length of my set and we get 5 again.
Nothing too crazy but one two three four five.
Remember it only counts the unique things because this will never gets entered.
It's a set and alternatively we can also convert this into a list.
If I click Run here you'll see that I now have my set as a list and then we can also do let's say my
set dot copy and actually copy my set into something let's say new or new set and then this will be
completely different or a new copy then this original one.
So let's test the set this new set if I use a method that we may have seen before which is my set dot
clear which as you can imagine clears the set and I click Run I have that new set but when I try and
print are all set which was my set it's going to be empty an empty set but the true power of sets comes
in the next couple methods that I'm going to show you and sets have quite a few methods but don't worry
most of them are quite similar.
So let's explore that in the next video.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.