- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
16 Explanation of Set Operation in Python Programming.
So a set is an unordered collection that no duplicate elements and no indexing.
So let's see how we can use set in Python.
So you can declare a variable and then is equal to.
And you defined the elements inside in our curly bracket.
So you can define multiple values here.
For example one or more to come up by coma for almost seven or nine.
But keep in mind that in set you cannot have duplicate values. so each value in set must be a unique value.
for example what happens when we define a set but some duplicate values.
I'm going to just declare this set and press enter here and this set is created.
Now whenever I tried to access the values inside the set then it's going to give me this set and you
can see that tool which was a duplicate which we have defined here is removed from this set.
So our set always have unique values.
And if you define a set with duplicate values it's going to remove the duplicate values and only save
the unique values in the set.
So let's see some of the method related to set . and the first method L E N method.
And you can find the length of set using this L E N method and the name of the set. which it
returns the length of set.
You can also use add a function.
So A dot and to add element in a set.
So I wanted to add 10 for example into my set. I can use this and then press enter . and once again when
I tried to get the values inside that SET . hey you can see 10 is added to this set. but this time it
will only be added if it's already not there in the set.
If it's already there in the set nothing will happen.
So let's try to add once again then to the set which already have a set.
And once again you will see that nothing happens inside the set because 10 was already there.
Now if you want to add multiple values in a set. you can use update method.
So you can call this method which is update and then inside brackets you need to provide
these multiple values.
So let's add some values into the set.
So I'm going to add 15 18 17 let's say and 14.
OK.
And then press enter.
And now I will see the values inside the set and you can see all these values are added to the set.
You can also remove the values from the set. now I can call a method name remove and let's say I want
to remove 18 from the set.
I can just give the element and then press enter and once again I will try to access the set and you
can see 18 is removed from this set.
Now there is a method called discard also.
So let's see how we can use this method.
Discard works similar to the remove method.
So for example I want to remove this 17 from my set.
I can write 17 here and it works fine.
**************************************************************************
please like and follow us in Facebook and Instagram.
facebook: https://www.facebook.com/TechnologyTv
Instagram: https://www.instagram.com/heikhamsingh
Twitter: https://twitter.com/hanandkumarsing
Видео 16 Explanation of Set Operation in Python Programming. канала Free Tutorial TV
So let's see how we can use set in Python.
So you can declare a variable and then is equal to.
And you defined the elements inside in our curly bracket.
So you can define multiple values here.
For example one or more to come up by coma for almost seven or nine.
But keep in mind that in set you cannot have duplicate values. so each value in set must be a unique value.
for example what happens when we define a set but some duplicate values.
I'm going to just declare this set and press enter here and this set is created.
Now whenever I tried to access the values inside the set then it's going to give me this set and you
can see that tool which was a duplicate which we have defined here is removed from this set.
So our set always have unique values.
And if you define a set with duplicate values it's going to remove the duplicate values and only save
the unique values in the set.
So let's see some of the method related to set . and the first method L E N method.
And you can find the length of set using this L E N method and the name of the set. which it
returns the length of set.
You can also use add a function.
So A dot and to add element in a set.
So I wanted to add 10 for example into my set. I can use this and then press enter . and once again when
I tried to get the values inside that SET . hey you can see 10 is added to this set. but this time it
will only be added if it's already not there in the set.
If it's already there in the set nothing will happen.
So let's try to add once again then to the set which already have a set.
And once again you will see that nothing happens inside the set because 10 was already there.
Now if you want to add multiple values in a set. you can use update method.
So you can call this method which is update and then inside brackets you need to provide
these multiple values.
So let's add some values into the set.
So I'm going to add 15 18 17 let's say and 14.
OK.
And then press enter.
And now I will see the values inside the set and you can see all these values are added to the set.
You can also remove the values from the set. now I can call a method name remove and let's say I want
to remove 18 from the set.
I can just give the element and then press enter and once again I will try to access the set and you
can see 18 is removed from this set.
Now there is a method called discard also.
So let's see how we can use this method.
Discard works similar to the remove method.
So for example I want to remove this 17 from my set.
I can write 17 here and it works fine.
**************************************************************************
please like and follow us in Facebook and Instagram.
facebook: https://www.facebook.com/TechnologyTv
Instagram: https://www.instagram.com/heikhamsingh
Twitter: https://twitter.com/hanandkumarsing
Видео 16 Explanation of Set Operation in Python Programming. канала Free Tutorial TV
Комментарии отсутствуют
Информация о видео
13 декабря 2023 г. 23:17:23
00:12:25
Другие видео канала
