Skip to contentSkip to navigation

Module 3

Data Structures

Master sequences, slicing, strings, list algorithms, and powerful comprehensions.

// Lessons

6

// Quiz questions

90

// Reading time

90 min

// Exam length

15 Q

// Coding exercises

10

  1. 1Lists & Indexing OperationsCreate ordered mutable sequences, access sub-ranges via slicing, and manage element mutations. 15 min 15 questions
  2. 2List Algorithms & Memory ModelsCompare in-place sorting vs sorted(), implement custom keys, and avoid shallow copying bugs. 15 min 15 questions
  3. 3Tuples & Sequence UnpackingProtect data integrity with immutable records, single-item syntax, and structural unpacking. 15 min 15 questions
  4. 4Strings & Text RepresentationUnderstand unicode character indexing, slice extraction, and memory immutability constraints. 15 min 15 questions
  5. 5String Methods & Text SanitizationClean and transform raw text data using casing transformations, whitespace trimming, and split-join pipelines. 15 min 15 questions
  6. 6List ComprehensionsTransform collections with concise, idiomatic inline mapping, filtering, and nested iterations. 15 min 15 questions

Coding practice: write it yourself

Real Python, real checks: write your answer, press Run checks, and keep going until it passes. (4 exercises)

All module exercises

Coding practice needs an account. Sign in or create a free ID to run these exercises.

Lab 1: Shopping basket

Sign-in required

Starting from ["rice", "oil"], append "dates", then print the whole list followed by its length on one line — like ['rice', 'oil', 'dates'] 3.

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

Lab 2: Top score

Sign-in required

Cricket scores: [88, 101, 45]. Print the highest score without sorting the list manually — there is a built-in for that.

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

Lab 3: Unique visitors

Sign-in required

The log ["Mim", "Rafi", "Mim"] has repeats. Print how many UNIQUE visitors there are.

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

Lab 4: Safe marks lookup

Sign-in required

With marks = {"Mim": 78}, print Mim's marks AND Rafi's using .get() with default 0 — expecting 78 0.

Coding Practice is Locked

Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and earn XP.

References & Further Reading

Related entries from PyLabs's own reference library.

  • copy() (Make a shallow copy of a list.)
  • get() (Look up a value safely without raising a KeyError if missing.)
  • split() (Split text into a list of pieces.)
  • union() (Return a new set with elements from this set and all others.)