Skip to main content

5 docs tagged with "Data Structures"

View all tags

Introduction to Python Collections Module: namedtuple, deque, Counter

We've now mastered Python's four core collection types. But what happens when you need a more specialized tool? The collections module in Python's standard library provides high-performance, specialized container datatypes. In this article, we'll introduce three of the most useful: namedtuple, deque, and Counter.

Lists (Part 1): Introduction to lists, declaring and initializing lists

Following our exploration of combining loops and conditionals, this article kicks off a new series on Working with Collections, starting with an introduction to Python lists. This concept is essential for storing and manipulating groups of data and is a foundational element in modern Python development.

Sets: Unordered collections of unique items. Set operations.

We've explored ordered collections like lists and **tuples**, and the key-value world of dictionaries. Now we introduce the final core collection type: the set. Sets are all about uniqueness and are modeled after the mathematical concept of a set.

Tuples: Immutable lists, creating and using tuples

After mastering the flexibility of lists in Part 1 and Part 2, we now turn to their close relative they are immutable. Understanding this distinction is key to writing robust and efficient Python code.