- Лайфстайл
- Недвижимость
- Здоровье
- Природа
- Дизайн
- Техника и оборудование
- Бизнес и предпринимательство
- Искусство
- Религия
- Строительство и ремонт
- Сад и огород
- Аудиокниги
- Кулинария
- Интервью
- Развлечения
- Лайфхаки
- Эзотерика
- Охота и рыбалка
- Наука
- Политика
- Психология
- Аудио
- Технологии и интернет
- Красота
- Телепередачи
- Детям
- Аниме
- Хобби
- Видеоигры
- Юмор
- Образование
- Спорт
- Разное
- Путешествия
- Животные
- Новости и СМИ
- Мультфильмы
- Музыка
- Сериалы
- Фильмы
- Авто-мото
42 Lists and Tuples | Python [ COMPLETE COURSE ]
As we mentioned earlier, in Python Programming strings and lists are both examples of sequences. Strings are sequences of characters, and are immutable. Lists are sequences of elements of any data type, and are mutable. The third sequence type is the tuple. Tuples are like lists, since they can contain elements of any data type. But unlike lists, tuples are immutable. They’re specified using parentheses instead of square brackets.
You might be wondering why tuples are a thing, given how similar they are to lists. Tuples can be useful when we need to ensure that an element is in a certain position and will not change. Since lists are mutable, the order of the elements can be changed on us. Since the order of the elements in a tuple can't be changed, the position of the element in a tuple can have meaning. A good example of this is when a function returns multiple values. In this case, what gets returned is a tuple, with the return values as elements in the tuple. The order of the returned values is important, and a tuple ensures that the order isn’t going to change. Storing the elements of a tuple in separate variables is called unpacking. This allows you to take multiple returned values from a function and store each value in its own variable.
Видео 42 Lists and Tuples | Python [ COMPLETE COURSE ] автора Молодые питонисты в действии
Видео 42 Lists and Tuples | Python [ COMPLETE COURSE ] автора Молодые питонисты в действии
Информация
3 декабря 2023 г. 19:34:55
00:03:52
Похожие видео

















![Déployer un système de détection d'intrusion HIDS WAZUH [Webinar]](http://pic.rutubelist.ru/video/98/61/9861d50740fb7b1c084f9a8409f30c9c.jpg?size=s)



