Offline-ready notes · progress saves on this device
Project LibraryStudy workspace →
Courses/Professional Skills/Lesson 7

Lesson 7 of 8

Python Data Structures

Read the overview in
English overview

Choose between lists, tuples, and dictionaries to store related information, then use common methods and libraries to solve practical problems.

10:26 lectureBeginner12 video chapters30 flashcards + 30 questions
Official Binary Tree uploadBinaryTree Comprehensive Curriculum Week 7Published 2026-08-09 · embedded with chapters, checkpoints, deep notes, and a project

Four clear stages

Learn → Project → Check → Finish

Watch and work through the lecture
  1. 1LearnWatch and work through the lectureUse the chapter notebook and answer each video checkpoint.Do this now
  2. 2ProjectCode a shop inventory trackerPlan it, create it, then prove it meets the definition of done.Next
  3. 3CheckAnswer all 30 questionsCorrect weak spots using the explanation after each answer.Next
  4. 4FinishMark the lesson completeThen move to AI in Everyday Life.Next
Course outlineProfessional Foundations

Interactive lecture

Watch, pause, think, apply.

Choose the right Python collection for changing, fixed, or labeled data, then combine lists, tuples, dictionaries, and libraries in a checked inventory program.

0:003 thinking points marked10:26

Numbered markers show where the video will pause. Seeking past one opens the first unanswered check.

Connecting to the lecture…Open on YouTube ↗

Chapter-by-chapter lecture notebook

Everything in the video, organized for learning

Week 7 moves from isolated variables to deliberate data models. The lecture’s rule—if it changes, consider a list; if it is fixed, consider a tuple; if fields need names, use a dictionary—guides every practice decision.

Source reviewed10:26 lectureReviewed against the public lecture and its English captions; automatic-caption wording was checked against the lesson context.
12

video chapters mapped into notes, examples, and a concrete action.

This is a detailed learning companion reconstructed from the reviewed lecture—not a verbatim transcript.
01
0:00 in the lectureFrom first programs to organized data
What the video is teaching

A data structure groups related values so a program can store, retrieve, update, and traverse them consistently. The structure itself communicates expectations about order, change, and lookup.

Do not choose from habit. Ask whether order matters, whether the collection changes, and whether each value needs a meaningful label.

What to noticeModel choice

A learner’s changing course list is a list; a fixed screen resolution can be a tuple; a learner profile is a dictionary with fields such as name and level.

Do this before continuing

Classify six real examples as list, tuple, or dictionary and defend each choice with change, order, and lookup requirements.

Replay this chapter on YouTube ↗
02
1:09 in the lectureWhat a data structure does
What the video is teaching

A data structure groups related values so a program can store, retrieve, update, and traverse them consistently. The structure itself communicates expectations about order, change, and lookup.

Do not choose from habit. Ask whether order matters, whether the collection changes, and whether each value needs a meaningful label.

What to noticeModel choice

A learner’s changing course list is a list; a fixed screen resolution can be a tuple; a learner profile is a dictionary with fields such as name and level.

Do this before continuing

Classify six real examples as list, tuple, or dictionary and defend each choice with change, order, and lookup requirements.

Replay this chapter on YouTube ↗
03
1:42 in the lectureLists, zero-based indexing, and mutability
What the video is teaching

Lists use zero-based indexes, so index 0 is the first item. They can contain mixed values, but consistent item shapes make loops and checks much safer.

Methods change state in different ways: append adds at the end, remove deletes a matching value, pop removes by position and returns it, and sort reorders the list itself. The sorted function preserves the original and returns a new list.

What to noticeMutation trace

Start with three movies, append one, remove one, then predict both the final order and len(movies) before running the code.

Do this before continuing

Write the movie-list activity from the lecture, then add tests for removing an absent title and sorting without losing the original order.

Replay this chapter on YouTube ↗
04
2:38 in the lectureList methods: append, remove, pop, sort
What the video is teaching

Lists use zero-based indexes, so index 0 is the first item. They can contain mixed values, but consistent item shapes make loops and checks much safer.

Methods change state in different ways: append adds at the end, remove deletes a matching value, pop removes by position and returns it, and sort reorders the list itself. The sorted function preserves the original and returns a new list.

What to noticeMutation trace

Start with three movies, append one, remove one, then predict both the final order and len(movies) before running the code.

Do this before continuing

Write the movie-list activity from the lecture, then add tests for removing an absent title and sorting without losing the original order.

Replay this chapter on YouTube ↗
05
3:28 in the lectureMovie-list coding activity
What the video is teaching

Lists use zero-based indexes, so index 0 is the first item. They can contain mixed values, but consistent item shapes make loops and checks much safer.

Methods change state in different ways: append adds at the end, remove deletes a matching value, pop removes by position and returns it, and sort reorders the list itself. The sorted function preserves the original and returns a new list.

What to noticeMutation trace

Start with three movies, append one, remove one, then predict both the final order and len(movies) before running the code.

Do this before continuing

Write the movie-list activity from the lecture, then add tests for removing an absent title and sorting without losing the original order.

Replay this chapter on YouTube ↗
06
3:57 in the lectureTuples and fixed records
What the video is teaching

Tuples are ordered and indexed like lists, but they are immutable after creation. That constraint can prevent accidental changes and allows appropriate tuples to serve as dictionary keys.

Immutability does not make every tuple automatically better or faster in a meaningful way. Use a tuple when the record is conceptually fixed, not merely because the syntax is shorter.

What to noticeFixed pair

A location such as (0.3476, 32.5825) should remain one ordered coordinate pair, while a route containing many changing locations belongs in a list.

Do this before continuing

Convert three list examples into tuples only where the data is truly fixed. Explain why each remaining list must stay mutable.

Replay this chapter on YouTube ↗
07
5:06 in the lectureChoose list versus tuple
What the video is teaching

Tuples are ordered and indexed like lists, but they are immutable after creation. That constraint can prevent accidental changes and allows appropriate tuples to serve as dictionary keys.

Immutability does not make every tuple automatically better or faster in a meaningful way. Use a tuple when the record is conceptually fixed, not merely because the syntax is shorter.

What to noticeFixed pair

A location such as (0.3476, 32.5825) should remain one ordered coordinate pair, while a route containing many changing locations belongs in a list.

Do this before continuing

Convert three list examples into tuples only where the data is truly fixed. Explain why each remaining list must stay mutable.

Replay this chapter on YouTube ↗
08
5:19 in the lectureDictionaries and key-value access
What the video is teaching

A dictionary maps unique keys to values. Bracket access is direct but fails on a missing key; get can supply a safe default. Assigning a key adds or updates data, while items exposes key-value pairs for loops.

Values may themselves be lists or dictionaries, which lets programs model realistic records. Keep key names consistent and validate missing values instead of assuming every record is complete.

What to noticeInventory record

Each product is a dictionary with name and quantity; the inventory is a list of those dictionaries because products repeat the same record shape.

Do this before continuing

Complete the inventory Code Lab: update a quantity, preserve original product order, and return every low-stock name.

Replay this chapter on YouTube ↗
09
6:35 in the lectureStudent-grade dictionary activity
What the video is teaching

A dictionary maps unique keys to values. Bracket access is direct but fails on a missing key; get can supply a safe default. Assigning a key adds or updates data, while items exposes key-value pairs for loops.

Values may themselves be lists or dictionaries, which lets programs model realistic records. Keep key names consistent and validate missing values instead of assuming every record is complete.

What to noticeInventory record

Each product is a dictionary with name and quantity; the inventory is a list of those dictionaries because products repeat the same record shape.

Do this before continuing

Complete the inventory Code Lab: update a quantity, preserve original product order, and return every low-stock name.

Replay this chapter on YouTube ↗
10
7:27 in the lectureLibraries and import
What the video is teaching

A library packages reusable code behind functions and objects. Built-in modules such as random, math, datetime, and json ship with Python; external libraries such as requests or pandas require installation in a compatible environment.

Import only what the task needs, read the library documentation, and avoid treating third-party code as automatically safe or correct. Libraries reduce reinvention but do not remove responsibility.

What to noticeReal stack

A web program may use dictionaries for API responses, lists for posts, json for data exchange, and requests for transport.

Do this before continuing

Choose one built-in library, use one function in a tiny program, and explain the input, output, and failure case.

Replay this chapter on YouTube ↗
11
8:40 in the lectureModel a social application
What the video is teaching

A library packages reusable code behind functions and objects. Built-in modules such as random, math, datetime, and json ship with Python; external libraries such as requests or pandas require installation in a compatible environment.

Import only what the task needs, read the library documentation, and avoid treating third-party code as automatically safe or correct. Libraries reduce reinvention but do not remove responsibility.

What to noticeReal stack

A web program may use dictionaries for API responses, lists for posts, json for data exchange, and requests for transport.

Do this before continuing

Choose one built-in library, use one function in a tiny program, and explain the input, output, and failure case.

Replay this chapter on YouTube ↗
12
9:31 in the lectureStructure-selection rule
What the video is teaching

A library packages reusable code behind functions and objects. Built-in modules such as random, math, datetime, and json ship with Python; external libraries such as requests or pandas require installation in a compatible environment.

Import only what the task needs, read the library documentation, and avoid treating third-party code as automatically safe or correct. Libraries reduce reinvention but do not remove responsibility.

What to noticeReal stack

A web program may use dictionaries for API responses, lists for posts, json for data exchange, and requests for transport.

Do this before continuing

Choose one built-in library, use one function in a tiny program, and explain the input, output, and failure case.

Replay this chapter on YouTube ↗

Deep explanations

The ideas behind each chapter

Use these sections when the video moves quickly or you need another example.

011:09

Model related information as one unit

A data structure groups related values so a program can store, retrieve, update, and traverse them consistently. The structure itself communicates expectations about order, change, and lookup.

Do not choose from habit. Ask whether order matters, whether the collection changes, and whether each value needs a meaningful label.

Model choice

A learner’s changing course list is a list; a fixed screen resolution can be a tuple; a learner profile is a dictionary with fields such as name and level.

Try it now

Classify six real examples as list, tuple, or dictionary and defend each choice with change, order, and lookup requirements.

021:42

Use list order and mutation deliberately

Lists use zero-based indexes, so index 0 is the first item. They can contain mixed values, but consistent item shapes make loops and checks much safer.

Methods change state in different ways: append adds at the end, remove deletes a matching value, pop removes by position and returns it, and sort reorders the list itself. The sorted function preserves the original and returns a new list.

Mutation trace

Start with three movies, append one, remove one, then predict both the final order and len(movies) before running the code.

Try it now

Write the movie-list activity from the lecture, then add tests for removing an absent title and sorting without losing the original order.

033:57

Protect fixed records with tuples

Tuples are ordered and indexed like lists, but they are immutable after creation. That constraint can prevent accidental changes and allows appropriate tuples to serve as dictionary keys.

Immutability does not make every tuple automatically better or faster in a meaningful way. Use a tuple when the record is conceptually fixed, not merely because the syntax is shorter.

Fixed pair

A location such as (0.3476, 32.5825) should remain one ordered coordinate pair, while a route containing many changing locations belongs in a list.

Try it now

Convert three list examples into tuples only where the data is truly fixed. Explain why each remaining list must stay mutable.

045:19

Use dictionaries for named facts

A dictionary maps unique keys to values. Bracket access is direct but fails on a missing key; get can supply a safe default. Assigning a key adds or updates data, while items exposes key-value pairs for loops.

Values may themselves be lists or dictionaries, which lets programs model realistic records. Keep key names consistent and validate missing values instead of assuming every record is complete.

Inventory record

Each product is a dictionary with name and quantity; the inventory is a list of those dictionaries because products repeat the same record shape.

Try it now

Complete the inventory Code Lab: update a quantity, preserve original product order, and return every low-stock name.

057:27

Borrow tested capabilities through libraries

A library packages reusable code behind functions and objects. Built-in modules such as random, math, datetime, and json ship with Python; external libraries such as requests or pandas require installation in a compatible environment.

Import only what the task needs, read the library documentation, and avoid treating third-party code as automatically safe or correct. Libraries reduce reinvention but do not remove responsibility.

Real stack

A web program may use dictionaries for API responses, lists for posts, json for data exchange, and requests for transport.

Try it now

Choose one built-in library, use one function in a tiny program, and explain the input, output, and failure case.

Language of the lesson

Know these ideas

Data structure
An organized representation for storing and operating on related information.
List
An ordered, mutable Python collection written with square brackets.
Tuple
An ordered, immutable Python collection commonly written with parentheses.
Dictionary
A mutable mapping from unique keys to values.
Index
A numeric position in an ordered collection; Python indexing starts at zero.
Library
Reusable code packaged for import into a program.
Mutation
An in-place change to an existing value or collection.

Reason like a practitioner

Misconceptions to correct

  • Tuples and lists differ only in brackets.A tuple’s immutability changes when it is appropriate and what operations it supports.
  • Dictionary values are retrieved only by position.Dictionaries retrieve values by meaningful keys.
  • A library means the result is automatically correct.You still verify inputs, behavior, versions, permissions, and edge cases.
Transfer challenge

Design the data model for a small community marketplace: user profiles, fixed map coordinates, product inventory, and comments. Implement the inventory portion in Code Lab and pass every deterministic check.

Lesson project · Python program

Code a shop inventory tracker

A checked list-of-dictionaries inventory that updates quantities and reports low-stock products.

0%0 of 4 checks
Your brief

Model a small shop inventory as a list of dictionaries. Add an item, update its quantity, and print the names of products that are low in stock.

  1. 1
    Plan the work

    State the goal, audience or user, and the evidence a strong result needs. Explain how List changes your plan.

  2. 2
    Build and test

    Model a small shop inventory as a list of dictionaries. Add an item, update its quantity, and print the names of products that are low in stock.

  3. 3
    Prove and improve

    Use Tuple and Dictionary to check the result. Record one piece of evidence, one correction, and one improvement you would make next.

Offline referenceRead the independent walkthrough and practice notes

Why this lesson matters

Choose between lists, tuples, and dictionaries to store related information, then use common methods and libraries to solve practical problems.

The goal is not to memorize vocabulary. By the end of the lesson, you should be able to use the ideas in a realistic situation, explain the reason for your choices, and check whether the result actually works for the intended person or task.

Learning objectives

  • Explain List in your own words.
  • Apply Tuple to a realistic classroom or community example.
  • Connect List with Dictionary when making a decision.
  • Complete the practice task and reflect on one improvement.

Core ideas

1. List

An ordered, mutable collection suited to data that may grow, shrink, or change while a program runs.

In practice: Look for this idea while you complete the lesson task. Pause before each major step and explain how List changes what you choose, create, or check.

2. Tuple

An ordered, immutable collection suited to values that belong together and should not be changed.

In practice: Look for this idea while you complete the lesson task. Pause before each major step and explain how Tuple changes what you choose, create, or check.

3. Dictionary

A mutable collection of key-value pairs that retrieves a value by a meaningful key rather than only by position.

In practice: Look for this idea while you complete the lesson task. Pause before each major step and explain how Dictionary changes what you choose, create, or check.

How the ideas connect

Start with List to understand the foundation of the lesson. Use Tuple to turn that understanding into an action. Then apply Dictionary to check the quality, safety, or usefulness of the result. The three ideas are strongest when you can explain their relationship rather than treating them as separate definitions.

Guided walkthrough

  1. Name the goal. In one sentence, write what you are trying to understand, create, or improve.
  2. Make a prediction. Before touching a device, use List and Tuple to predict what a strong result should look like.
  3. Complete the task. Model a small shop inventory as a list of dictionaries. Add an item, update its quantity, and print the names of products that are low in stock.
  4. Check the outcome. Use Dictionary to inspect the result. Ask what worked, what did not, and what evidence supports your judgment.
  5. Explain and revise. Tell a partner what you changed and why. Make one small improvement, then compare the new result with the first one.

Worked classroom scenario

Imagine two learners sharing one device. The first learner is the driver and performs the steps; the second is the navigator and reads the goal, predicts the next step, and checks the result. Halfway through the task, switch roles. Both learners should be able to explain how List, Tuple, and Dictionary appeared in the work.

If no device is available, complete the same reasoning on paper: sketch the screen or result, label each decision, and describe what you would test when a device becomes available.

Common mistakes and fixes

  • Rushing into the tool: Write the goal and prediction first so every click or step has a reason.
  • Copying without understanding: After each major step, explain it in your own words to a partner.
  • Accepting the first result: Compare the outcome with the goal and make at least one deliberate improvement.
  • Letting one person control a shared device: Rotate driver and navigator roles so both learners think and practice.

Independent practice

Model a small shop inventory as a list of dictionaries. Add an item, update its quantity, and print the names of products that are low in stock.

For an extra challenge, adapt the task for a different audience or community need. Write two sentences explaining what changed and which lesson idea guided your decision.

Check your understanding

  1. How would you explain List to someone new to the topic?
  2. What is one realistic example of Tuple outside this classroom?
  3. When might Dictionary prevent a weak, unsafe, or confusing result?
  4. How are List and Tuple connected?
  5. What evidence would convince you that your practice result works?
  6. If you repeated the activity tomorrow, what would you improve first and why?

Key takeaway

Choose between lists, tuples, and dictionaries to store related information, then use common methods and libraries to solve practical problems.

You are ready to move on when you can explain the three core ideas, complete the practice without copying, and describe one improvement using evidence from your result.