Study Key A Content Processing Service for Students and Teachers, for Study and Evaluation
A Content Processing Service for Students and Teachers, for Study and Evaluation

Unit 4: Computational Structures

5 reading sections · 15 MCQs · 6 short · 5 long questions

4.1 Lists

A **list** stores many data items (**elements**) in a specific order; each element has an **index** (first = 0). ``` items = ["Decorations", "Snacks", "Cold drinks", "Plates", "Balloons"] print(items) ``` ## Properties 1. **Dynamic size** – items can be added or removed at any time; the list grows or shrinks automatically. 2. **Index-based access** – items[0] is the first item, items[1] the second ... 3. **Ordered collection** – items keep the order in which they were added. ## Operations ``` party_list = ["Buy decorations", "Buy snacks", "Buy cold drinks"] party_list.insert(0, "Invite friends") # insert at a position party_list.append("Buy plates") # add at the end party_list.remove("Buy snacks") # delete by value (first occurrence) party_list.pop(0) # delete by index if "Buy cold drinks" in party_list: # search with in print("Buy cold drinks is on the list.") ``` ## Applications Storing and manipulating collections of records or values; implementing **stacks** (LIFO) and **queues** (FIFO).
Something went wrong. Reload ✕