By Fatskills Exam Guides Team — the exam nerds behind 28,500+ quizzes and 2.1M practice questions across 500+ global exams.
Grade 7 Computer Science – Data Structures: Lists & Dictionaries
"If you’re building a game where players collect items—like potions, weapons, or coins—how do you keep track of everything they pick up without losing anything or mixing up what’s what? Why can’t you just dump all the items into one big pile and hope the computer remembers which is which?"
Imagine your backpack at school. If you just threw everything inside—pencils, a water bottle, your math homework, a granola bar—it’d be a mess. You’d waste time digging for your homework when the bell rings. Now imagine your backpack had pockets: one for school supplies, one for snacks, one for electronics. That’s how lists and dictionaries work in code—they’re like labeled pockets for data.
A list is like a single pocket where you toss things in order. If you collect coins in a game, you might store them as coins = [5, 10, 25, 5]—each number is a coin’s value, and the order matters (the first coin you picked up is first in the list). A dictionary is like a pocket with smaller labeled compartments. If you’re tracking a player’s inventory, you might use inventory = {"potion": 3, "sword": 1, "shield": 0}—each item has a name (key) and a count (value).
coins = [5, 10, 25, 5]
inventory = {"potion": 3, "sword": 1, "shield": 0}
Key Vocabulary:- List: An ordered collection of items, like a line of people where each person’s spot matters. Example: A playlist where the first song is always first, even if you add more songs later. Grade 7 Note: Lists can hold any data type (numbers, words, even other lists), but the order is fixed unless you change it.
Dictionary: A collection of key-value pairs, like a phone book where you look up a name (key) to find a number (value). Example: A school locker combination where the locker number (key) unlocks a specific combination (value). Grade 7 Note: Keys must be unique (no two "potion" entries), but values can repeat (you can have 3 potions and 3 shields).
Index: The position of an item in a list, starting at 0 (like the first seat in a row is seat 0). Example: In fruits = ["apple", "banana", "cherry"], "banana" is at index 1. Grade 7 Note: Forgetting that indexes start at 0 is a classic mistake—it’s like thinking the first floor of a building is floor 1 when it’s actually floor 0.
fruits = ["apple", "banana", "cherry"]
Key-Value Pair: A single entry in a dictionary, like a word and its definition in a glossary. Example: In grades = {"math": 90, "science": 85}, "math" is the key and 90 is the value. Grade 7 Note: Keys are like labels on folders—they help you find what you need fast.
grades = {"math": 90, "science": 85}
How This Appears on State Assessments (Grade 7):- Multiple Choice: Questions test whether you can read or modify lists/dictionaries (e.g., "What is the value of inventory["potion"] if inventory = {"potion": 2, "key": 1}?"). Distractor Patterns: - Confusing keys and values (e.g., picking "potion" instead of 2). - Off-by-one errors (e.g., thinking the first item in a list is at index 1). - Assuming dictionaries are ordered (e.g., thinking "potion" comes before "key" alphabetically).
inventory["potion"]
inventory = {"potion": 2, "key": 1}
Short Answer: You might be asked to write code to add an item to a list or update a dictionary value (e.g., "Write a line of code to add 'torch' to the inventory dictionary with a value of 1"). Proficient Response: inventory["torch"] = 1 (correct syntax, no typos). Developing Response: inventory[torch] = 1 (missing quotes around the key) or inventory.append("torch") (using list syntax on a dictionary).
inventory
inventory["torch"] = 1
inventory[torch] = 1
inventory.append("torch")
Debugging: You’ll see a snippet of code with an error (e.g., trying to access a key that doesn’t exist) and be asked to fix it. Proficient Response: "The code will crash because 'armor' isn’t a key in inventory. You should add inventory["armor"] = 0 first."
inventory["armor"] = 0
Model Proficient Response (Short Answer):Prompt: "Given the list scores = [88, 92, 78], write code to change the second score to 95." Response:
scores = [88, 92, 78]
scores[1] = 95
Why It’s Proficient: - Correctly uses index 1 (not 2) for the second item.- Uses assignment (=) to update the value.- No extra steps or errors.
=
Mistake 1: Off-by-One Index ErrorsPrompt: "What is the value of fruits[2] if fruits = ["apple", "banana", "cherry"]?" Common Wrong Response: "banana" (student thinks the first item is at index 1).Why It Loses Credit: The question asks for the third item (index 2), but the student gives the second.Correct Approach: - Remember indexes start at 0.- Count the items: "apple" (0), "banana" (1), "cherry" (2).- Answer: "cherry".
fruits[2]
"banana"
"cherry"
Mistake 2: Using List Syntax on DictionariesPrompt: "Write code to add 'map' to the inventory dictionary with a value of 1." Common Wrong Response: inventory.append("map") (or inventory["map"] without assigning a value).Why It Loses Credit: append() is for lists, not dictionaries. Dictionaries need a key and a value.Correct Approach: - Use inventory["map"] = 1 to add a key-value pair.- Check that the key is in quotes (unless it’s a variable).
inventory.append("map")
inventory["map"]
append()
inventory["map"] = 1
Mistake 3: Assuming Dictionaries Are OrderedPrompt: "If inventory = {"potion": 2, "key": 1}, what is the first item in the dictionary?" Common Wrong Response: "potion" (student assumes dictionaries are ordered like lists).Why It Loses Credit: Dictionaries in Python (before 3.7) are unordered—there is no "first" item. The question is a trick! Correct Approach: - Dictionaries don’t have order (unless you’re using Python 3.7+ and the question specifies it).- Answer: "Dictionaries don’t have a set order, so there is no 'first' item."
"potion"
Within Computer Science: Lists → Loops — Loops let you process every item in a list (e.g., adding up all the coins in coins = [5, 10, 25]). Without lists, loops would have nothing to iterate over.
coins = [5, 10, 25]
Across Subjects: Dictionaries → Biology (Taxonomy) — A dictionary is like a biological classification system (e.g., {"kingdom": "Animalia", "phylum": "Chordata"}). Each key (kingdom, phylum) maps to a specific value (Animalia, Chordata), just like a dictionary maps keys to values.
{"kingdom": "Animalia", "phylum": "Chordata"}
Outside School: Lists → Spotify Playlists — A playlist is a list where the order matters (your "Chill Vibes" playlist starts with a specific song). If Spotify used a dictionary instead, you’d lose the order and just get a random song each time.
"If you have a list of 1,000 items and a dictionary with 1,000 key-value pairs, which one would let you find a specific item faster—and why? What if the list was sorted?"
Pointer Toward the Answer:- Dictionaries are much faster for finding items because they use a trick called "hashing" (like a super-fast index). It’s like having a phone book where you can jump straight to "Smith" without reading every name.- A sorted list is faster than an unsorted one (you can use "binary search"), but it’s still slower than a dictionary. Think of it like flipping to the middle of a phone book and narrowing down—it’s better than reading every name, but not as fast as jumping straight to "Smith." - In college, you’ll learn about "Big O notation," which measures how fast operations like searching are. Dictionaries are usually O(1), while lists are O(n).
Join 4M+ learners. Unlock unlimited quizzes, wrong-answer tracking, flashcards + reminders, study guides, and 1-on-1 challenges.