Python data structure using tuple the immutable object details with supported methods and function
https://www.plus2net.com/python/tuple.php
We will be storing multiple data using a single variable like tuple. There is no concept of array in Python so we will be using these sequential data types to store these data. Here we will discuss more about tuple and you can watch our previous video on List with details comparison between tuple , list , set and dictionary .
Creating a tuple
We can create an empty tuple by using its constructor.
my_tuple=tuple()
Let us create a tuple and print the output
my_tuple=(‘alex’,’Ronn’, ‘John’)
print(my_tuple)
Using Range to create a tuple
We can use range to create a tuple with data from the range. Let us fill a tuple with elements taken from a range.
x=range(5,50,10)
my_tuple=tuple(x)
print(my_tule)
Unpacking a tuple
We can display all elements without any brackets ( as a list ) by using unpacking my_tuple=('Alex','Ronald','John')
print(*my_tuple)
Displaying list based on position
Print(my_tuple[2])
The first element is my_tuple[0] , second element is my_tuple[1]. The last element is my_tuple[-1], all elements starting from 0 position my_tuple[0:]
All elements from 1 to 4 is my_tuple[1:4]
Displaying all elements by looping
my_tuple=['Alex','Ronald','John']
for i in my_tuple:
print(i)
Methods for tuple
Count(x) : Returns number of matching x value inside the tuple
Index(x) : returns position of the input value
Using in we can search the presence of an element inside the tuple.
my_tuple=['Alex','Ronald','John']
if 'John' in my_tuple:
print("Yes, included ")
else:
print("No, not included")
We can get total number of elements present inside a tuple by using len()
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python data structure using tuple the immutable object details with supported methods and function», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.