# iGCSE Computer Science - Distance Learning

Course Information
Data Representation (Number Systems)
Text, Sound, & Images
Data Storage & Compression
Tutor Marked Assignment 1
Communication & Internet Technologies
Tutor Marked Assignment 2
Hardware & Software
Tutor Marked Assignment 3
Computer Software
Tutor Marked Assignment 4
Data Security
Tutor Marked Assignment 5
Ethics & AI
Tutor Marked Assignment 6
Algorithm Design & Problem Solving
Tutor Marked Assignment 7
Programming (Python)
Tutor Marked Assignment 8 (Programming)
Databases
Mock Exams

# Using 2D Arrays in Programming (2023 Specification Only)

We’ve already looked at how data structures (arrays) are used to save data in a single dimension. When data is saved as a 1D array, this is often referred to as a list. When related data can be saved in lists, sometimes 1D arrays are used in parallel to create a digital table. This method is even more efficient when a table is created using a 2D array.

As we are using Python to create 2D arrays, there are several things that it is important to be aware of:

This is not a “true” array.

Python actually creates a matrix as a 2D data structure which is an array of arrays. A True 2D array will save rows and columns. This is why the syntax to read from the array looks different in python and pseudocode.

Look at the two examples below:

``````#Python

myTable = [[0,1,2],
[0,1,2],
[0,1,2]

print (myTable[1][1])``````
``````#Pseudocode

myTable <-- [[0,1,2],
[0,1,2],
[0,1,2]]

OUTPUT myTable[1,1]

``````

In the second example, the data is treated as if it has mathematical co-ordinates. This means that we identify the row, then the column separated by a comma (along the corridor & up the stairs)