Question 1 of Quiz 03

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/18

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

19 Terms

1
New cards
Which data structures are sequences?
list (Only list is an ordered sequence. set and dict are unordered collections.)
2
New cards
Which data structures are mutable?
list, set, dict (All three can be modified after creation.)
3
New cards
Which can contain duplicate values?
list, dict (list: duplicates allowed. dict: values can duplicate, but keys must be unique. set enforces uniqueness.)
4
New cards
Which uses key-value pairs?
dict (Example: {"name": "Alice"}. list and set store individual elements.)
5
New cards
Which does NOT guarantee element order?
set (Even in modern Python, set is unordered. list and dict preserve insertion order.)
6
New cards
Which allows indexing with [ ]?
list, dict (list: by position (e.g., lst[0]). dict: by key (e.g., d["key"]). set is unindexed.)
7
New cards
Most efficient for checking if an item exists?
set, dict (O(1) lookup time. list is O(n) since it checks each item sequentially.)
8
New cards
Best for ordered elements + duplicates?
list (Example: ["a", "b", "a"] keeps order and allows repeats.)
9
New cards
Which uses .add() to insert elements?
set (Example: s.add(3). list uses .append()/.insert(), dict uses [key] = value.)
10
New cards
Best for iterating + modifying a sequence?
list (Optimized for sequential access and in-place changes.)
11
New cards
Best for PID → email lookups?
dict (Example: {"12345": ""}. Fast key-based retrieval.)
12
New cards
Literal syntax uses { }?
set, dict (set: {1, 2, 3}. dict: {"a": 1}. list uses [ ].)
13
New cards
Literal syntax uses [ ]?
list (Example: [1, 2, 3]. set/dict use { }.)
14
New cards
Can be iterated with for..in?
list, set, dict (All are iterable. dict iterates over keys by default.)
15
New cards
Works with len()?
list, set, dict (All return the number of items. dict counts key-value pairs.)
16
New cards
Best for set operations (union/intersection)?
set (Methods like s1.union(s2) are native to set.)
17
New cards
Best for ordered messages in a chat app?
list (Keeps insertion order: ["msg1", "msg2"].)
18
New cards
Best for counting word frequencies?
dict (Example: {"word": 5}. Efficient increments with counts[word] += 1.)
19
New cards
Allows custom index types (e.g., strings)?
dict (Keys can be str, int, tuple, etc. list only uses integer indices.)