Topic 1 · 4.1.1 · Free
Topic Notes · Easy summaries with diagrams
Chapter 4 — Chapter 4 — Computational Structures
0 of 6 steps done ✓ (5 topics + Exercise)
Topic 1 of 5
📘Easy summary
A list is an ordered collection of items stored in square brackets: marks = [85, 90, 78]. Properties: dynamic size (items can be added or removed and the list automatically adjusts), ordered (indexed from 0), mutable (items can be changed), and heterogeneous (can store different data types). Operations: append() adds an item at the end, insert(index, item) adds at a position, remove(item) and pop() delete, len() gives the length, the in keyword checks if an item exists, and slicing extracts parts. Two variable names assigned to the same list (b = a) refer to one object, so a change through one appears in the other; use a.copy() to make an independent copy. Applications: storing marks, to-do lists, shopping carts.
⭐Key points
- Dynamic, ordered, mutable.
- append() end; insert() at index.
- in checks membership.
🔬Diagram
🌿Real-life example
a = [1, 2]; b = a; b.append(3) → a is also [1, 2, 3].
💡Exam tip
- Use copy() to avoid shared-list surprises.
✅Quick check
1. Adds item at end:
2. 'in' with a list:
Practice this chapter
Lock it in with flashcards and exam-style MCQs.