Sequences are an abstract concept that summarizes four behaviors an object may or may not exhibit. Sequences are
Examples are the list
, tuple
, but also the str
types.
Objects that exhibit all behaviors except being ordered are referred to as collections.
The objects inside a sequence are called its elements and may be labeled with a unique index, an int
object in the range $0 \leq \text{index} < \lvert \text{sequence} \rvert$.
list
objects are mutable. That means we can change the references to the other objects it contains, and, in particular, re-assign them.
On the contrary, tuple
objects are like immutable lists: We can use them in place of any list
object as long as we do not need to mutate it. Often, tuple
objects are also used to model records of related fields.