10.19 Hands-on Exercises
Practice programs reinforcing Python list concepts -- an inventory manager class, a todo app, a log analyzer, a CSV processor, and mini …
Practice programs reinforcing Python list concepts -- an inventory manager class, a todo app, a log analyzer, a CSV processor, and mini …
Frequently asked and scenario-based Python list interview questions covering list vs tuple, append() vs insert(), sort() vs sorted(), …
Preferring a list comprehension over a manual loop when it stays readable, choosing append() over insert(0, ...), converting to a set for …
The most common list bugs in Python -- off-by-one IndexError, silently skipping elements by mutating a list while iterating over it, and the …
Lists as the natural in-memory shape of file and log contents, plus real infrastructure patterns -- server inventories, filtering Amazon EC2 …
Classic list algorithms built from tools covered earlier in this chapter -- reverse, order-preserving deduplication with dict.fromkeys(), …
The time complexity of every core list operation, why a list uses somewhat more memory than an equivalent tuple, and why append() is O(1) …
sort() vs sorted() -- in-place versus a new list -- plus linear search (works on any list, O(n)) and binary search (requires a sorted list, …
Why b = a shares one list instead of copying it, the list-specific shallow-copy shortcuts (copy() and l[:]), how mutation is visible through …
Creating, accessing, and updating nested lists using chained indices, iterating a 2D matrix row by row, and why [[0]*n]*n builds a matrix of …
Four idiomatic ways to visit every element of a list -- for, while, enumerate(), and zip() -- plus list comprehensions as the compact, …
Global functions that accept a list as an argument -- len(), max(), min(), sum(), sorted(), any(), and all() -- as distinct from methods …
A consolidated reference for every built-in list method, grouped by what it does -- add (append, extend, insert), remove (remove, pop, …
Concatenation and repetition build brand-new lists, membership testing is a linear scan, and comparison works element-by-element and …
The four ways to remove items from a list -- remove() by value, pop() by index (which returns what it removes), clear() to empty it, and the …
Updating an element by index, growing a list with append() and extend(), inserting at a position, and replacing a whole range at once with …
Positive and negative indexing, chaining indices into nested lists, IndexError, and slicing with l[start:stop:step] -- including reversal, …
Empty lists, list literals, the list() constructor, splitting a string into characters, materializing a range(), and building nested or …
What a list is, its core characteristics, why it's Python's general-purpose array, and how it's actually stored in memory as a resizable, …