Lecture 15: Collections in Python: Lists смотреть онлайн
Collections in Python: Lists
Collections in Python, are containers that are used to store collections of data, collection types are built-in in Python.
There are four collection data types in the Python programming language:
List is a collection which is ordered, indexed and elements in that list are changeable. Allows duplicate members in the list.
Tuple is a collection which is ordered, indexed and unchangeable elements in that collection. Allows duplicate members in the tuple.
Set is a collection which is unordered, unindexed and unchangeable elements. No duplicate members allowed in sets.
Dictionary is a collection which is unordered, changeable and indexed. No duplicate members.
When choosing a collection type, it is useful to understand the properties of that type and choose correct type for a particular data set.
Lists are just like the arrays declared in other languages. But the most powerful thing is that list need not be always homogenous like array.
A single list can contain strings, integers, as well as other types of objects.
A list is a collection which is ordered, indexed.
Lists are mutable, i.e., they can be altered once declared.
In Python lists are written with square brackets.
Example:
L = [“amol”,21,99.99 ]
print(L)
Lists can also be used for implementing stacks and queues data structures.
We can access the list items by referring to the index number:
L = ["amol", 21,99.99 ]
print(L[0]) # 0 index means first element in the list
Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second last item and so on.
We can specify a range of indexes by specifying where to start and where to end the range.
When specifying a range, the return value will be a new list with the specified items.
print(L[3:5]) # List will be printed from stating index 3 which is included to index 5, which is excluded
By leaving out the start value, the range will start at the first item.
Example:
List = [“amol”,”suraj”,”kedar”,”samir”,”vijay”]
print(List[:3]) # returns items from start to kedar string
By leaving out the end value, the range will go on to the end of the list.
List = [“amol”,”suraj”,”kedar”,”samir”,”vijay”]
print(List[2:]) # returns items from second element to last element
Specify negative indexes if you want to start the search from the end of the list.
List = [“amol”,”suraj”,”kedar”,”samir”,”vijay”]
print(List[-3:-1]) # returns items from kedar to samir
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Lecture 15: Collections in Python: Lists» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.