Module 4: Python Data Structures
Beginner 16 chapters
40. Introduction to Lists
Meet the Python list: an ordered, changeable collection that can hold many values. Learn how to create one, read items, change them, add items and loop over a list.
41. List Creation and Indexing
Learn the different ways to create lists, including list(), range() and repetition, and master positive and negative indexing, nested lists and the IndexError.
42. List Methods
Learn the main list methods: append, insert, extend, remove, pop, sort, reverse, index and count, and understand which ones change the list and what they return.
43. List Slicing
Learn how to cut pieces out of a list with the start:stop:step slice syntax, use negative indexes, reverse a list, and assign to slices.
44. Nested Lists
Learn how to store lists inside lists, read and change items with two indexes, loop over rows and columns, and avoid the shared-row trap.
45. List Comprehension
Learn list comprehensions: build new lists in one readable line with a loop, an optional if filter, an if-else expression, and nested loops.
46. Introduction to Tuples
Meet the tuple, an ordered collection that cannot be changed: how to create it, index and slice it, unpack it, and decide when to choose it over a list.
47. Tuple Methods
Learn the two tuple methods, count and index, and the built-in functions and operators that work with tuples, such as len, min, max, sum, sorted, + and *.
48. Tuple Packing and Unpacking
Learn how to pack values into a tuple and unpack them into variables, including swapping, star unpacking, nested unpacking, and returning several values from a function.
49. Introduction to Sets
Meet the set: an unordered collection of unique, hashable items. Learn how to create sets, remove duplicates, test membership quickly, and use the basic set operators.
50. Set Methods
Learn the methods of a set: add, update, remove, discard, pop, clear, copy, the set-algebra methods, the update variants, and the subset and superset tests.
51. Set Operations
Learn how to combine and compare sets with union, intersection, difference and symmetric difference, using both operators and methods.
52. Introduction to Dictionaries
Learn what a dictionary is, how to create one, read values by key, add and change entries, delete them, and loop over keys and values.
53. Dictionary Methods
Learn the most useful dictionary methods: get, setdefault, update, pop, popitem, keys, values, items, copy, clear and the merge operators.
54. Nested Dictionaries
Learn how to store dictionaries inside dictionaries, read and change deeply stored values safely, and loop over nested data such as student records or settings.
55. Dictionary Comprehension
Learn to build dictionaries in one readable line with dictionary comprehensions, including filtering, transforming, swapping keys and values, and combining two lists.