#programming #array
[[Outcome 1 - Programming#5. characteristics of data structures, including| Outcome 1 - KK5]]
Why do we need other data structures? Can't we just use variables for everything?
- 1 variable contains one piece of data
- Accessed by individual name
- Not good when you need to group large quantities of related data
- Cannot work on a group of variables in one operation.
## One-dimensional array (single data type and integer index)
A storage structure with many storage locations addressable by index number
![[Pasted image 20251118125407.jpeg|500]]
A one-dimensional array has one-column (or row) with several rows (or columns) equal to its length. Hence why we call it a one-dimensional array as one of its dimensions in only one in length.
Here is a table which is an example of a 1D array.
| index | value |
| ----- | ------- |
| 0 | "Bob" |
| 1 | "Alice" |
| 2 | "Mike" |
Arrays normally only contain ONE data type which needs to be declared with the array.
![[Pseudocode#Array]]
## 2D Arrays
![[2d-array.webp]]
While 1D arrays have a purpose there are many situations were you might need to store more then one column of data. This is where 2D arrays (Arrays with more than one column) come in.
Classic examples would be brightness values of a pixel,
In Python arrays in the traditional sense do not exist. Instead we use ***lists*** which can contain many data types and has a dynamic length (meaning it changes to the required size).
## Python Arrays
![[Lists (Array)]]