Posts

Python for Beginners - Part 3: Data Structures - Organizing Your Data

Welcome back to our Python coding course! In Part 2, we mastered control flow, allowing our programs to make decisions and loop through code. Now, in Part 3, we'll dive into Data Structures . These are fundamental ways to store and organize collections of data, making your programs more powerful and efficient. Python offers several built-in data structures: Lists, Tuples, Dictionaries, and Sets. 1. Lists Lists are ordered, changeable (mutable) collections that allow duplicate members. They are written with square brackets [] . Creating a List # Empty list my_list = [] # List with mixed data types fruits = ["apple", "banana", "cherry"] numbers = [1, 2, 3, 4, 5] mixed_list = ["hello", 123, True, 3.14] print(f"Fruits: {fruits}") print(f"Numbers: {numbers}") Accessing List Items (Indexing) List items are indexed, starting from 0 for the first item. Negative indexing means starting from the end, where -1 is the last item. f...