🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, in which you will discover one of the most used Data Types: Tuples in Python - and all of the operations you can perform on Tuples in Python (Create, Pack, Unpack, Access, Update, Remove, Check, Loop, Merge, Sort)
▬▬▬▬ 📖 Content ▬▬▬▬
🖥️ Python provides another kind of Data Type, called a Tuple. Tuples in Python are a lot like Lists in Python, and they are used to collect objects in order. Thus, everything you have learned about Lists is true, for tuples as well.
A Tuple in Python is defined by placing a comma-separated sequence of items, in parentheses. Tuple is an ordered collection of values, accessed by index, and contains any sort of objects - like: numbers, strings, lists, or even other nested tuples. Lists and Tuples can also contain duplicate members! Except that tuples are immutable, which means you theoretically cannot: add, delete or change items inside the tuple - once created. Nonetheless, you can iterate through a tuple, with a simple for loop as well.
Why use a tuple in Python, instead of a list?
✔ Program execution is faster when manipulating a tuple ;
✔ Sometimes you do not want data to be modified. If the values in the collection are meant to remain constant for the life of the program, using a tuple instead of a list protects your data from accidental modification ;
✔ There is another Python data type called a Dictionary, which requires as keys, a value that is of an immutable type. A tuple can be used for this purpose, whereas a List cannot be.
🎯 In this video, you will discover: How to create a tuple in Python. But also what are all the operations you can perform on it, in order to: create a tuple, pack or unpack a tuple, add, remove, or access an item. Or even search for a specific item inside of a tuple, using for loops. Plus, some of the built-in methods you can use on tuples, in Python.
Let's play this video, stick around and watch until the end! 👍🏻
- Digital Academy™ 🎓
▬▬ EXERCISE ▬▬
In this exercise, You will have to:
* Declare a tuple with the values 'red', 'green', 'blue', 'yellow' and 'black'.
* Unpack this tuple into multiple variables, within their respective names.
* If the tuple has a value 'green' and that it corresponds to the 2nd item, update the variable yellow with the value 'orange', then change the order of the items by swapping the values of the variables red and black.
* Pack All these variables into a new tuple.
* Iterate through the items until you meet the value 'orange'. Once you have encountered this item: convert this tuple into a list, use its index to update the value 'orange' back to its original value 'yellow', and convert it back to your tuple again. Then, break out of the loop.
* Use the slicing operator so you do not keep the last value.
* Print out the result.
👇🏻Please, do tell me in the comment: What result did you get?
▬▬▬▬ 🎬 Watch NEXT ▬▬▬▬
○ PYTHON OPERATORS: [ Ссылка ]
○ PYTHON CONDITIONALS (IF, ELSE, ELIF): [ Ссылка ]
○ PYTHON FOR Loops: [ Ссылка ]
○ PYTHON DICTIONARY: [ Ссылка ]
🌐 Blog: [ Ссылка ]
📖 [PLAYLIST] Complete Python Development Course for Beginners: [ Ссылка ]
▬▬▬▬ 🔗 Links ▬▬▬▬
🌐 Blog: [ Ссылка ]
🛒 Shopping: [ Ссылка ]
📘 [BOOK] Python for Absolute Beginners: [ Ссылка ]
👨🏼🏫 [ALL COURSES] [ Ссылка ]
💌 Weekly Newsletter for Developers: [ Ссылка ]
▬▬▬▬ ⏱ Timestamps ▬▬▬▬
00:00 | Introduction
01:12 | Definition Tuple
01:55 | Why use a Tuple in Python?
02:28 | Python Tuple - Create a Tuple in Python & Syntax
04:09 | Python Tuple - Pack & Unpack a Tuple in Python + ValueError
05:55 | Python Tuple - Access Item (Indexing, Negative indexing, Slicing)
07:20 | Python Tuple - Add & Update Item inside a Tuple (Immutable)
08:11 | Python Tuple - Remove Item (Convert into a List, del keyword)
08:34 | Python Tuple - Check Existence of an Item in a Tuple (Membership)
09:08 | Python Tuple - Iterate through Items of a Tuple (FOR Loop)
10:20 | Python Tuple - Merge Items and Sort two Tuples in Python
11:38 | Python Tuple - Practical Exercise (+ Solution)
14:32 | Python Tuple - Methods & Functions
15:09 | Conclusion
#Python #Tutorial #Beginners #Tuple
▬▬▬▬ ⭐ FOLLOW US ▬▬▬▬
✧ [ Ссылка ]
✧ [ Ссылка ]
✧ [ Ссылка ]
✧ [ Ссылка ]
✧ [ Ссылка ]
▬▬▬▬ ⚡ SUPPORT US ▬▬▬▬
✧ [ Ссылка ]
✧ [ Ссылка ]
✧ [ Ссылка ]
✧ [ Ссылка ]
✧ [ Ссылка ]
Ещё видео!