Arrays
An array is a fixed length data structure that stores multiple related values of the same data type under a single identifier.
Accessing items in an array
Arrays use zero indexing meaning the first item in an array is in position 0. This means the last item is always in position n - 1, where n is the number of items in the array.
Attempting to access an item from a position not in the array results in an out-of-range error.
2 dimensional arrays
A 2-dimensional array is an array where each element in the array is itself an array e.g. scores = [[10,12,13,15],[8,11,14,12],[15,10,8,12]].
A 2D array is declared by passing two parameters, first the number of sub-arrays and second the number of elements in each sub-array e.g. array gameboard[3,3]
Accessing items in a 2D array
To access data in a 2D array you pass the array name and two values. The first is which sub-array to look in and the second is which position within that sub-array. If we have
an array scores = [[10,12,13,15],[8,11,14,12],[15,10,8,12]] then scores[2,1] would be 10.
2 dimensional arrays
We pass 2 parameters when assigning to a 2D array, the first is which sub-array and the second which position in that array. gameboard[1,1] = "X" would place an X in the center
of the middle array.
Records
A record is a way to group together related data of different data types. The pseudocode for declaring records, creating an instance of a record, assigning new values to
fields in a record, and accessing values of the fields in records is shown below.
In practice records can be implemented using lists in Python or by storing the records in textfiles. Alternatively, a database can be used and each record in a database table
would be a record. It is standard to access all records of one type using a while not end of file loop.