filmov
tv
Python Tutorial for Beginners 14 - Python Tuples
Показать описание
In this video I am going to show What are Tuples and How to use Tuples in python. Python Tuples are another kind of sequence that functions similar to a list - they have elements which are indexed starting at 0. But Tuples are "immutable" i.e. Unlike a list, once you create a tuple, you cannot alter its contents.
So Tuple is an an immutable sequence which is Very similar to a list but Tuple is created it cannot be changed
Format: tuple_name = (item1, item2)
Tuples support operations as lists i.e.Subscript indexing for retrieving elements, Also Methods such as index, Built in functions such as len, min, max, Slicing expressions, The in, +, and * operators. Tuples do not support the methods like append, remove
insert, reverse, sort.
Advantages for using tuples over lists:
1)Processing tuples is faster than processing lists
2)Tuples are safe
3)Some operations in Python require use of tuples
list(tuple_var) function: converts tuple to list
tuple(list_var) function: converts list to tuple
The list of all functions which can be use with Python Tuples:
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
So Tuple is an an immutable sequence which is Very similar to a list but Tuple is created it cannot be changed
Format: tuple_name = (item1, item2)
Tuples support operations as lists i.e.Subscript indexing for retrieving elements, Also Methods such as index, Built in functions such as len, min, max, Slicing expressions, The in, +, and * operators. Tuples do not support the methods like append, remove
insert, reverse, sort.
Advantages for using tuples over lists:
1)Processing tuples is faster than processing lists
2)Tuples are safe
3)Some operations in Python require use of tuples
list(tuple_var) function: converts tuple to list
tuple(list_var) function: converts list to tuple
The list of all functions which can be use with Python Tuples:
['__add__', '__class__', '__contains__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'count', 'index']
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!
Комментарии