PYTHON FUNDAMENTALS: PROGRAMMING FOUNDATIONS / L07WORKING WITH DATA STRUCTURES
课程 · 12 · 07 / 12
LESSON 07 · BEGINNER · 45 MIN · ◆ 3 INSTRUMENTS

Working with Data Structures

Learn advanced operations on lists, dictionaries, and sets. Includes sorting, filtering, and transforming data.

TIP

Learning Objectives: After this lesson, you'll master advanced operations on lists, dictionaries, and sets, learn to combine different data structures effectively, and implement common algorithms for sorting, filtering, and transforming data.

Combining Data Structures

Real-world data often requires combining different data structures. Let's explore powerful patterns for working with complex data:

FIG. 02Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 02Interactive Python code execution environment

Advanced List Operations

FIG. 04Data Structure Visualizer
INTERACTIVE
LOADING INSTRUMENT
Fig. 04Interactive visualization of Python data structures
FIG. 06Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 06Interactive Python code execution environment

Sorting Algorithms Visualization

Let's implement and visualize a simple sorting algorithm:

FIG. 08Algorithm Stepper
INTERACTIVE
LOADING INSTRUMENT
Fig. 08Step-through execution of algorithms and code
FIG. 10Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 10Interactive Python code execution environment

Advanced Dictionary Operations

FIG. 12Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 12Interactive Python code execution environment

Data Transformation Patterns

FIG. 14Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 14Interactive Python code execution environment

Working with Multiple Data Structures

FIG. 16Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 16Interactive Python code execution environment

Algorithm Implementation Practice

FIG. 18Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 18Interactive Python code execution environment

Practice Exercises

Exercise 1: Data Analysis Pipeline

FIG. 20Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 20Interactive Python code execution environment

Exercise 2: Social Network Analysis

FIG. 22Python Code Executor
INTERACTIVE
LOADING INSTRUMENT
Fig. 22Interactive Python code execution environment

Key Takeaways

Complex data structures combine lists, dictionaries, and sets for real-world problems
Sorting and filtering are fundamental operations for data processing
Algorithm implementation helps understand computational thinking
Data transformation converts raw data into useful structures
Performance matters - choose the right data structure for the task
Search algorithms like binary search provide efficient data retrieval
Pattern recognition helps identify common data processing needs
Nested structures enable modeling of complex relationships

Next Steps

In the next lesson, we'll learn about functions - how to create reusable code blocks, understand parameters and return values, and explore scope concepts that make your code more organized and maintainable.


Ready to make your code more organized and reusable? The next lesson will teach you the power of functions!


Further Reading

Visualize It

  • Python Tutor — for nested structures (list-of-dicts, dict-of-lists), Python Tutor draws the reference graph so you stop guessing where shared mutations come from.
  • VisuAlgo — Sorting & Searching — animated walkthroughs of the algorithms behind sorted(), bisect, and in.

Official Docs

Tutorials

Books

  • Book: Fluent Python — Part II ("Data Structures"). The canonical reference.
  • Book: Effective Python — Items 13–25 cover comprehensions, generators, dict tricks, and class-based abstractions.