Module 4
Dictionaries and Sets
// Lessons
6
// Quiz questions
90
// Reading time
105 min
// Exam length
15 Q
// Coding exercises
10
- 1Set Algebra & Venn OperationsCompute mathematical set unions, intersections, symmetric differences, and subset tests. 15 min 15 questions
- 2Dictionaries & Hash MapsStore associative key-value data with fast O(1) hash lookups and key immutability constraints. 15 min 15 questions
- 3Dictionary Methods & Key MergingPerform safe lookups with .get(), group data with .setdefault(), and merge maps with the pipe operator. 15 min 15 questions
- 4Set Creation & DeduplicationEliminate duplicate items, enforce element uniqueness, and achieve fast O(1) membership checks. 20 min 15 questions
- 5Collections Module ToolsCount frequencies with Counter, eliminate missing-key errors with defaultdict, and use namedtuples. 20 min 15 questions
- 6Nested Data StructuresNavigate and construct multi-layered JSON trees, nested lists, and deep copying workflows. 20 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)
Coding practice needs an account. Sign in or create a free ID to run these exercises.
Lab 1: Config lookup
Given config = {"host": "localhost", "port": 5432}, print Server running on localhost:5432 using values from the dictionary.
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: Update fruit stock
Given stock = {"apple": 10, "orange": 5}, add 7 more apples and add "banana": 12. Print: {'apple': 17, 'orange': 5, 'banana': 12}.
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: Shared interests
Find common items between a = {"python", "sql", "react"} and b = {"sql", "docker", "python"}. Print the sorted list: ['python', 'sql'].
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: Letter frequency
Count occurrences of each character in "mississippi" using a dictionary. Print the count of 's': s: 4.
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.