Practice & Assessment
Test your understanding of Data Structures
Multiple Choice Questions
5What does `a = [1, 2, 3]; b = a; b.append(4); print(a)` output?
Which of the following can be used as a dictionary key?
What is the result of `set([1, 2, 2, 3, 3, 3])`?
What is the output of `(42)` vs `(42,)` in Python?
What is the key advantage of a generator expression over a list comprehension?
Coding Challenges
1Word frequency counter
Given a string of space-separated words, return a dictionary mapping each unique word (lowercased) to its frequency count. Input: a single string, e.g. `'apple banana apple cherry banana apple'`. Output: a dict like `{'apple': 3, 'banana': 2, 'cherry': 1}`. Constraints: use a dictionary, handle case insensitivity, no external libraries. Estimated time: 15-20 minutes.
Mini Project
Student Grade Book
Build a grade book using dictionaries and lists. Store student names as keys and a list of numeric scores as values. Implement functions to: add a student, add a score to a student, compute a student's average, find the top scorer, and print a formatted summary table. Input comes from hardcoded data or a simple input loop. Output is a printed summary. Use list comprehensions to compute averages and filter students with averages above a threshold. Demonstrate dictionary iteration, list methods, and set operations to find students present in both a 'passed' and 'attended' set.
