A=[1,2,3] B=[4,5,6]
Which one of the following statements results in ?
Solve 2+ Python Data Structures: Lists, Sets and Dictionaries previous year questions for GATE DA with answers and detailed solutions. Free sample questions below.
This chapter is about predicting the final state of Python data structures after a sequence of operations.
Focus on:
append, extend, insert, pop, remove, sort, reverse.+.+=.Focus on:
in.A, B = A - B, B - A.If you can answer these four questions, most list and set tracing problems become mechanical.
A Python list is an ordered collection. The position of each item matters, and the list can be changed after creation.
items = [10, 20, 30]
| Property | Meaning |
|---|---|
| Ordered | [1, 2, 3] is different from [3, 2, 1] |
| Mutable | Elements can be changed, added, or removed |
| Duplicates allowed | [1, 1, 2] is valid |
| Indexed by position | First item is index 0, last is index -1 |
x = [10, 20, 30]
x[0] = 5 # replace item
x.append(40) # add one item at end
x.insert(1, 15) # insert at index 1
x.pop() # remove and return last item
x.remove(20) # remove first occurrence of 20
n = len(x) # length
x = [10, 20, 30]
x[0] = 5
x.append(40)
x.insert(1, 15)
| Step | Value of x |
|---|---|
| Start | [10, 20, 30] |
x[0] = 5 | [5, 20, 30] |
x.append(40) | [5, 20, 30, 40] |
x.insert(1, 15) | [5, 15, 20, 30, 40] |
The key idea is that the list changes in place. No new list is created by these operations.
A=[1,2,3] B=[4,5,6]
A={"this","that"}
B={"that","other"}
C={"other","this"}
while "other" in C:
if "this" in A:
A,B,C=A-B,B-C,C-A
if "that" in B:
A,B,C=C|A,A|B,B|C
Solve 2+ Python Data Structures: Lists, Sets and Dictionaries previous year questions for GATE DA with answers and detailed solutions. Free sample questions b
Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.
Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.
Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.
We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.
Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.
Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.
Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.
No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.
Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.