Offline-ready notes · progress saves on this device
Project LibraryStudy workspace →
Courses/Digital Literacy/Lesson 5

Lesson 5 of 5

Lists, Functions & Reusable Logic

Read the overview in
English overview

Store multiple values in indexed lists and organize repeated logic into functions with parameters, return values, and clear names.

5:42 lectureBeginner11 video chapters30 flashcards + 30 questions
Official Binary Tree uploadDigital Literacy Week 5Published 2026-08-06 · 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 reusable score analyzerPlan 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 completeFinish the course and review your progress tree.Next
Course outlineDigital Literacy

Interactive lecture

Watch, pause, think, apply.

Use list indexing and slicing safely, write reusable functions with parameters, and combine them in a Caesar-cipher project.

0:003 thinking points marked5:42

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

The lecture moves from ordered data to reusable behavior and ends with a cipher. This guide makes the relationships explicit.

Source reviewed5:42 lectureReviewed against the public lecture with timestamped slide sampling across the full runtime and cross-checked against the source lesson context.
11

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 lectureLogic, lists, and functions
What the video is teaching

Lists can hold multiple values, preserve order, allow duplicates, and change after creation. Indexes begin at zero; negative indexes count from the end.

Check length before uncertain access, use clear element types where possible, and remember that slicing excludes the stop index.

What to noticeWorked example

For five names, roster[0] is the first, roster[-1] is the last, and roster[1:3] contains the second and third.

Do this before continuing

Predict ten index and slice expressions, including two that should fail.

Replay this chapter on YouTube ↗
02
0:25 in the lectureCreate lists
What the video is teaching

Lists can hold multiple values, preserve order, allow duplicates, and change after creation. Indexes begin at zero; negative indexes count from the end.

Check length before uncertain access, use clear element types where possible, and remember that slicing excludes the stop index.

What to noticeWorked example

For five names, roster[0] is the first, roster[-1] is the last, and roster[1:3] contains the second and third.

Do this before continuing

Predict ten index and slice expressions, including two that should fail.

Replay this chapter on YouTube ↗
03
1:00 in the lectureOrder, mutation, duplicates, and indexes
What the video is teaching

Lists can hold multiple values, preserve order, allow duplicates, and change after creation. Indexes begin at zero; negative indexes count from the end.

Check length before uncertain access, use clear element types where possible, and remember that slicing excludes the stop index.

What to noticeWorked example

For five names, roster[0] is the first, roster[-1] is the last, and roster[1:3] contains the second and third.

Do this before continuing

Predict ten index and slice expressions, including two that should fail.

Replay this chapter on YouTube ↗
04
1:35 in the lectureAvoid index-out-of-range errors
What the video is teaching

Lists can hold multiple values, preserve order, allow duplicates, and change after creation. Indexes begin at zero; negative indexes count from the end.

Check length before uncertain access, use clear element types where possible, and remember that slicing excludes the stop index.

What to noticeWorked example

For five names, roster[0] is the first, roster[-1] is the last, and roster[1:3] contains the second and third.

Do this before continuing

Predict ten index and slice expressions, including two that should fail.

Replay this chapter on YouTube ↗
05
2:05 in the lectureSlice a list
What the video is teaching

Lists can hold multiple values, preserve order, allow duplicates, and change after creation. Indexes begin at zero; negative indexes count from the end.

Check length before uncertain access, use clear element types where possible, and remember that slicing excludes the stop index.

What to noticeWorked example

For five names, roster[0] is the first, roster[-1] is the last, and roster[1:3] contains the second and third.

Do this before continuing

Predict ten index and slice expressions, including two that should fail.

Replay this chapter on YouTube ↗
06
2:35 in the lectureLength, type, and list constructor
What the video is teaching

len reports item count, type reveals the runtime type, and list can construct a list from another iterable. These tools help validate assumptions.

Guard indexes with length or iteration rather than catching preventable errors after access.

What to noticeWorked example

If a user selects item 5 from a three-item list, the program explains the valid range before indexing.

Do this before continuing

Write a safe selection function that handles an empty list and an out-of-range position.

Replay this chapter on YouTube ↗
07
3:05 in the lectureDefine and call functions
What the video is teaching

A function is a named reusable block defined with def and executed when called. Parameters let one function operate on different inputs.

Name the action precisely, keep inputs and outputs clear, return results when another part of the program needs them, and avoid hidden global changes.

What to noticeWorked example

shift_letter(letter, amount) has a smaller, testable responsibility than a function that reads input, shifts text, prints, and saves a file at once.

Do this before continuing

Refactor one repeated calculation into a function and test it with three arguments.

Replay this chapter on YouTube ↗
08
3:35 in the lectureParameters and arguments
What the video is teaching

A function is a named reusable block defined with def and executed when called. Parameters let one function operate on different inputs.

Name the action precisely, keep inputs and outputs clear, return results when another part of the program needs them, and avoid hidden global changes.

What to noticeWorked example

shift_letter(letter, amount) has a smaller, testable responsibility than a function that reads input, shifts text, prints, and saves a file at once.

Do this before continuing

Refactor one repeated calculation into a function and test it with three arguments.

Replay this chapter on YouTube ↗
09
4:10 in the lectureNested functions
What the video is teaching

Nested functions can limit a helper to the scope where it is used, but unnecessary nesting can make testing harder. A Caesar cipher shifts letters around an alphabet while preserving non-letter decisions deliberately.

Separate encode, decode, single-character shift, and input validation. Test wraparound, uppercase or lowercase policy, spaces, punctuation, empty text, and negative shifts.

What to noticeWorked example

With a 3-letter shift, X wraps to A. Decoding applies the inverse shift and should recover the original message.

Do this before continuing

Build the encoder and decoder, then prove decode(encode(message, key), key) equals the original for five cases.

Replay this chapter on YouTube ↗
10
4:50 in the lectureCaesar cipher project
What the video is teaching

Nested functions can limit a helper to the scope where it is used, but unnecessary nesting can make testing harder. A Caesar cipher shifts letters around an alphabet while preserving non-letter decisions deliberately.

Separate encode, decode, single-character shift, and input validation. Test wraparound, uppercase or lowercase policy, spaces, punctuation, empty text, and negative shifts.

What to noticeWorked example

With a 3-letter shift, X wraps to A. Decoding applies the inverse shift and should recover the original message.

Do this before continuing

Build the encoder and decoder, then prove decode(encode(message, key), key) equals the original for five cases.

Replay this chapter on YouTube ↗
11
5:30 in the lectureEncoder and decoder challenge
What the video is teaching

Nested functions can limit a helper to the scope where it is used, but unnecessary nesting can make testing harder. A Caesar cipher shifts letters around an alphabet while preserving non-letter decisions deliberately.

Separate encode, decode, single-character shift, and input validation. Test wraparound, uppercase or lowercase policy, spaces, punctuation, empty text, and negative shifts.

What to noticeWorked example

With a 3-letter shift, X wraps to A. Decoding applies the inverse shift and should recover the original message.

Do this before continuing

Build the encoder and decoder, then prove decode(encode(message, key), key) equals the original for five cases.

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.

010:25

Use lists as ordered mutable sequences

Lists can hold multiple values, preserve order, allow duplicates, and change after creation. Indexes begin at zero; negative indexes count from the end.

Check length before uncertain access, use clear element types where possible, and remember that slicing excludes the stop index.

Worked example

For five names, roster[0] is the first, roster[-1] is the last, and roster[1:3] contains the second and third.

Try it now

Predict ten index and slice expressions, including two that should fail.

022:35

Inspect collection shape before acting

len reports item count, type reveals the runtime type, and list can construct a list from another iterable. These tools help validate assumptions.

Guard indexes with length or iteration rather than catching preventable errors after access.

Worked example

If a user selects item 5 from a three-item list, the program explains the valid range before indexing.

Try it now

Write a safe selection function that handles an empty list and an out-of-range position.

033:05

Give functions one clear responsibility

A function is a named reusable block defined with def and executed when called. Parameters let one function operate on different inputs.

Name the action precisely, keep inputs and outputs clear, return results when another part of the program needs them, and avoid hidden global changes.

Worked example

shift_letter(letter, amount) has a smaller, testable responsibility than a function that reads input, shifts text, prints, and saves a file at once.

Try it now

Refactor one repeated calculation into a function and test it with three arguments.

044:10

Compose functions in the cipher project

Nested functions can limit a helper to the scope where it is used, but unnecessary nesting can make testing harder. A Caesar cipher shifts letters around an alphabet while preserving non-letter decisions deliberately.

Separate encode, decode, single-character shift, and input validation. Test wraparound, uppercase or lowercase policy, spaces, punctuation, empty text, and negative shifts.

Worked example

With a 3-letter shift, X wraps to A. Decoding applies the inverse shift and should recover the original message.

Try it now

Build the encoder and decoder, then prove decode(encode(message, key), key) equals the original for five cases.

Language of the lesson

Know these ideas

List
An ordered mutable Python collection.
Index
A numeric position beginning at zero.
Slice
A selected range whose stop position is excluded.
Function
A named reusable block of behavior.
Parameter
A placeholder input named in a function definition.
Argument
A value supplied when calling a function.

Reason like a practitioner

Misconceptions to correct

  • The last valid index equals the list length.The last valid non-negative index is length minus one.
  • A function runs when it is defined.Definition creates it; a call executes it.
  • A cipher that works for one word is complete.Wraparound, case, punctuation, empty input, and round-trip tests still matter.
Transfer challenge

Build and test a Caesar encoder/decoder using lists or strings and small functions; include wraparound, punctuation, empty text, and round-trip evidence.

Lesson project · Python program

Code a reusable score analyzer

A checked function that averages a list, preserves reusable logic, and handles an empty list safely.

0%0 of 5 checks
Your brief

Write a function that receives a list of scores and returns the average. Test it with two lists, then explain what happens when the list is empty.

  1. 1
    Plan the work

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

  2. 2
    Build and test

    Write a function that receives a list of scores and returns the average. Test it with two lists, then explain what happens when the list is empty.

  3. 3
    Prove and improve

    Use Function and Parameter 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

Store multiple values in indexed lists and organize repeated logic into functions with parameters, return values, and clear names.

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 Index in your own words.
  • Apply Function to a realistic classroom or community example.
  • Connect Index with Parameter when making a decision.
  • Complete the practice task and reflect on one improvement.

Core ideas

1. Index

The numeric position of an item in an ordered collection; Python list indexes begin at zero.

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

2. Function

A named, reusable block of code designed to perform one clear task when it is called.

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

3. Parameter

A named input in a function definition that receives a concrete argument when the function is called.

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

How the ideas connect

Start with Index to understand the foundation of the lesson. Use Function to turn that understanding into an action. Then apply Parameter 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 Index and Function to predict what a strong result should look like.
  3. Complete the task. Write a function that receives a list of scores and returns the average. Test it with two lists, then explain what happens when the list is empty.
  4. Check the outcome. Use Parameter 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 Index, Function, and Parameter 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

Write a function that receives a list of scores and returns the average. Test it with two lists, then explain what happens when the list is empty.

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 Index to someone new to the topic?
  2. What is one realistic example of Function outside this classroom?
  3. When might Parameter prevent a weak, unsafe, or confusing result?
  4. How are Index and Function 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

Store multiple values in indexed lists and organize repeated logic into functions with parameters, return values, and clear names.

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.