Course Content
Python Data Structures
Python Data Structures
1. Mastering Python Lists
Creating Lists in Python: Declaring and Initializing ListsList Indexing in Python: Accessing Elements EfficientlyWorking with Nested Lists in PythonPython List Length: Measuring and Managing List SizeModifying Lists in Python: Updating and Changing ElementsUsing the append() Method: Adding Elements to ListsUsing the insert() Method: Placing Elements at Specific PositionsDeleting Elements in Python Lists: Removing Items SafelyUsing the remove() Method: Deleting Specific Elements from Lists
2. Mastering Python Dictionaries
Creating a Dictionary in Python: Storing Key-Value PairsAccessing Dictionary ValuesAccessing Dictionary KeysAdding Items to a Dictionary: Updating Key-Value PairsUsing the del Keyword: Removing Dictionary EntriesUsing the pop() Method: Deleting Elements with Return ValuesUsing the popitem() Method: Removing the Last Inserted ItemUsing the clear() Method: Emptying a Dictionary Completely
3. Mastering Python Tuples
Creating a Tuple in Python: Defining Immutable Data StructuresAccessing Elements in a Tuple: Indexing TechniqueConcatenating Tuples in Python: Merging Immutable SequencesDeleting Tuples in Python: Removing References to TuplesUpdating Tuples in PythonAdding Items to a Tuple: Alternative Approaches Using ListsCounting Elements in a Tuple: Using the count() MethodFinding Elements in a Tuple: Using the index() Method for Lookup
4. Mastering Python Sets
Creating a Set in Python: Defining Unordered CollectionsUsing the add() Method: Adding Single Elements to a SetUsing the update() Method: Merging Multiple Elements into a SetAccessing Elements in a Set: Iteration and Membership TestingUsing the remove() and discard() MethodsUsing the clear() Method: Removing All Elements from a Set
Concatenating Tuples in Python: Merging Immutable Sequences
In Python, it's possible to combine tuples. This involves forming a new tuple by merging two or more existing ones. You can accomplish this with the +
operator. Here's an example to illustrate.
movie_titles = ("Inception", "Interstellar", "Dunkirk") release_years = (2010, 2014, 2017) # Concatenate the tuples combined_tuple = movie_titles + release_years print(combined_tuple)
Task
Swipe to start coding
You are given: the tuple space_movies
and the list new_movies
.
- Convert the list into a tuple and assign the result to the variable
animal_movies
. - Use the
tuple
function to complete the first step. - Concatenate the two tuples and assign the result to the variable
movie_poster
.
Solution
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 3
Concatenating Tuples in Python: Merging Immutable Sequences
In Python, it's possible to combine tuples. This involves forming a new tuple by merging two or more existing ones. You can accomplish this with the +
operator. Here's an example to illustrate.
movie_titles = ("Inception", "Interstellar", "Dunkirk") release_years = (2010, 2014, 2017) # Concatenate the tuples combined_tuple = movie_titles + release_years print(combined_tuple)
Task
Swipe to start coding
You are given: the tuple space_movies
and the list new_movies
.
- Convert the list into a tuple and assign the result to the variable
animal_movies
. - Use the
tuple
function to complete the first step. - Concatenate the two tuples and assign the result to the variable
movie_poster
.
Solution
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 3