The Python List
The Python List
A mutable sequence type container.
Provides operations for managing the collection. Can grow and/or shrink as needed. Implemented using an array.
Chapter 2: Arrays ? ? 2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
1
List: Construction
The Python list interface provides an abstraction to the actual underlying implementation.
pyList = [ 4, 12, 2, 34, 17 ]
Chapter 2: Arrays ? ? 2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
2
List: Implementation
An array is used to store the items of the list.
Created larger than needed. The items are stored in a contiguous subset of the
array.
Chapter 2: Arrays ? ? 2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
3
List: Appending an Item
New items can be added at the end of the list.
pyList.append(50)
When space is available, the item is stored in the next slot.
Chapter 2: Arrays ? ? 2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
4
List: Appending an Item
What happens when the array becomes full?
pyList.append(18) pyList.append(64) pyList.append(6)
There is no space for value 6.
Chapter 2: Arrays ? ? 2011 John Wiley & Sons, Data Structures and Algorithms Using Python, by Rance D. Necaise.
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- python lesson 1 tufts university
- built in functions
- linked lists in python
- list comprehensions
- python cheat sheet python tutorials real python
- unit 5c merge sort
- unit testing in python github pages
- python tutorial stanford artificial intelligence laboratory
- python 3 beginner s reference cheat sheet http www
- sequences types lists tuples and