I'm teaching a programming class in Python, and I'd like to start with the mathematical definition of an array before discussing how arrays/lists work in Python.
Can someone give me a definition?
I'm teaching a programming class in Python, and I'd like to start with the mathematical definition of an array before discussing how arrays/lists work in Python.
Can someone give me a definition?
I'd go with comparing an array to a matrix. That way when you introduce arrays of arrays, the mental leap will be easier for your students to make.
An array is a tuple with elements taken from a specific set $S$. When the array can contain variables of a specific type, then the set is the set $S$ consists of all possible values of this type.
This is the most general definition, as a mathematician I don't talk about implementation details like the memory structure or the complexity of operations on the array.
It may be useful to consider more specific examples: If you fix a field $k$, consider a $k$ vector space $V$ of dimension $n$ and accept a specific data type of Pyhton as a representation of elements of $k$, you can interpret an one-dimensional $k$-array of length $n$ as a representation of a vector in $V$ (with respect to a fixed basis that is left implicit).
Similarly, one could interpret a two dimensional array of length n*n as representing a matrix, i.e. a linear transformation of $V$ etc.