CampusLearn
← CS 101 Introduction to Programming

Lists, dictionaries and choosing a data structure

Notes

Data structures decide how fast and how clearly your program handles collections of data. LISTS (ARRAYS) Ordered items by position. Great for sequences: scores, names, steps. Looking up by position is instant; searching for a value means checking each item. DICTIONARIES (MAPS) Key-value pairs. Great for lookups: student ID to name, word to definition. Lookup by key is instant. SETS Unordered unique items. Great for membership tests and removing duplicates. CHOOSING - Need order and position? List. - Need fast lookup by a name or ID? Dictionary. - Need uniqueness? Set. Practice: store five students and their grades in a dictionary, then print the top grade.

Quiz

1. Which structure automatically removes duplicate values?

2. You need fast lookups of student names by student ID. Which structure fits best?

Sign in to submit and securely grade your quiz.