Welcome to the Lists and Tuples section! Lists and Tuples are two of Python’s most commonly used data structures. They allow you to store, organize, and manage collections of data efficiently — making them essential for almost every Python program you’ll write.
├── 02_Lists_Tuples/
│ ├── 01_lists_basics.py
│ ├── 02_list_methods.py
│ ├── 03_tuples_basics.py
│ ├── 04_tuple_methods.py
│ ├── 05_unpacking.py
│ ├── practice_scripts/
│ └── README.md
In this section, you’ll explore:
- How to create and work with lists and tuples.
- The difference between mutable (lists) and immutable (tuples) data types.
- Common list methods used for adding, removing, and sorting elements.
- How to iterate through collections using loops.
- The concept of unpacking — assigning multiple variables from a single sequence.
| File Name | Description |
|---|---|
01_lists_basics.py |
Introduces list creation, indexing, slicing, and basic operations like adding or removing elements. |
02_list_methods.py |
Demonstrates list methods such as append(), insert(), remove(), pop(), extend(), and sort(). |
03_tuples_basics.py |
Explains tuple creation, indexing, and how tuples differ from lists. |
04_tuple_methods.py |
Covers tuple operations and functions like count() and index(). |
05_unpacking.py |
Demonstrates how to unpack lists or tuples into individual variables for cleaner, readable code. |
practice_scripts/ |
Contains practical exercises to help reinforce list and tuple concepts through hands-on coding. |
By completing this section, you’ll be able to: ✅ Create and manipulate lists effectively. ✅ Understand and use tuples for fixed collections of items. ✅ Apply list methods to organize and modify data. ✅ Use unpacking for simple, elegant variable assignments. ✅ Work confidently with sequences of varying lengths and data types.
Here are some fun exercises to try once you complete the lessons:
- Create a list of your favorite movies and print them using a loop.
- Sort a list of numbers in both ascending and descending order.
- Use tuple unpacking to swap the values of two variables without using a temporary variable.
- Create a list of lists to represent students and their marks, then find the student with the highest marks.
- Try converting a tuple into a list and back again to understand mutability.
Next Section → 03_Dictionaries_Sets