Subtopic Notes
H - 2D Arrays
Preq. Programming Basics
2D Arrays
- Type of array where each element is itself an array
- Can be visualized as a table with rows and columns
- Ideal for representing grid-like structures such as matrices, game boards or spreadsheets
- It consists of multiple rows and columns, where each element is uniquely identified by its row and column values.
- Applications: Images, screens and game boards
Example
A 2D array to store student grades for 4 subjects and 3 students.
| Student 1 | Student 2 | Student 3 | |
|---|---|---|---|
| Physics | 90 | 91 | 79 |
| Chemistry | 80 | 50 | 60 |
| Maths | 82 | 67 | 75 |
| Computer Science | 78 | 92 | 95 |
This can be represented in Python as the following
PYTHON
Python can be executed directly in the browser.
Editor — Python
Output
No output yet.
PSEUDOCODE
Pseudocode uses basic Cambridge-style keyword highlighting. Execution is not supported yet.
Editor — Pseudocode
