Data Structures Flashcards
7 cards from real PCEP practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Data Structures flashcards as text
What is the result of `[1, 2, 3] + [4, 5]`?
Answer: [1, 2, 3, 4, 5]
The `+` operator concatenates two lists into a single list.
Which method removes and returns the last element of a list?
Answer: pop()
`pop()` without arguments removes and returns the last element of the list.
What does `len({'a': 1, 'b': 2, 'c': 3})` return?
Answer: 3
`len()` on a dictionary returns the number of key-value pairs.
What is the output of `(1, 2, 3)[1:3]`?
Answer: (2, 3)
Slicing `[1:3]` on a tuple returns elements at index 1 and 2.
Which of the following creates an empty set?
Answer: set()
`{}` creates an empty dict, so `set()` is the only way to create an empty set.
What happens when you try to change a value in a tuple?
Answer: A TypeError is raised
Tuples are immutable; attempting to assign to an index raises a TypeError.
What is the result of `list(range(0, 10, 3))`?
Answer: [0, 3, 6, 9]
`range(0, 10, 3)` generates 0, 3, 6, 9 — stopping before 10.