2.3 Sequences
A sequence is an ordered collection of values. The sequence is a powerful, fundamental abstraction in computer science. Sequences are not instances of a particular built-in type or abstract data representation, but instead a collection of behaviors that are shared among several different types of data. That is, there are many kinds of sequences, but they all share common behavior. In particular, Length. A sequence has a finite length. An empty sequence has length 0. Element selection. A sequence has an element corresponding to any non-negative integer index less than its length, starting at 0 for the first element. Python includes several native data types that are sequences, the most important of which is the list. A list value is a sequence that can have arbitrary length. Lists have a large set of built-in behaviors, along with specific syntax to express those behaviors. We have already seen the list literal, which evaluates to a list instance, as well as an element selection express
2.3 Sequences c ⚬ mp ⚬ sing pr ⚬ grams Text Projects Tutor About Chapter 2 Hide contents 2.1 Introduction 2.1.1 Native Data Types 2.2 Data Abstraction 2.2.1 Example: Rational Numbers 2.2.2 Pairs 2.2.3 Abstraction Barriers 2.2.4 The Properties of Data 2.3 Sequences 2.3.1 Lists 2.3.2 Sequence Iteration 2.3.3 Sequence Processing 2.3.4 Sequence Abstraction 2.3.5 Strings 2.3.6 Trees 2.3.7 Linked Lists 2.4 Mutable Data 2.4.1 The Object Metaphor 2.4.2 Sequence Objects 2.4.3 Dictionaries 2.4.4 Local State 2.4.5 The Benefits of Non-Local Assignment 2.4.6 The Cost of Non-Local Assignment 2.4.7 Implement
Explore this link on the map →related reading
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- 4.2 Implicit Sequencescomposingprograms.com
- Reading 11: Recursive Data Typesweb.mit.edu
- Reading 13: Map, Filter, Reduceweb.mit.edu
- CSC 151 - Higher-order design, recursive and othereikmeier.sites.grinnell.edu
- 5. Data Structures — Python 3.14.6 documentationdocs.python.org
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- CSC 151 - List basicseikmeier.sites.grinnell.edu
- CSC 151 - The "big three" list operationseikmeier.sites.grinnell.edu
- A practical introduction to functional programmingmaryrosecook.com
- Structure and Interpretation of Computer Programsmitp-content-server.mit.edu
- Rust Iterator Cheat Sheetdanielkeep.github.io