Summary
An array is a data structure that stores multiple items of the same data type using index numbers. Arrays have a fixed size defined during declaration.
- Array — a data structure capable of storing multiple items of data at a time. Example: An array named 'fruits' can store items like 'Apple', 'Orange', 'Strawberry'.
- Index — a unique storage slot for each element in an array. Example: In the array 'fruits', 'Strawberry' is at index 2.
- 1-Dimensional Array — a basic array type that can be considered as a simple list of items. Example: DECLARE Fruits : ARRAY[0:4] OF STRING
- 2-Dimensional Array — can be considered as a table structure, defined as arrays within an array. Example: DECLARE StudentMarks: ARRAY[0:4, 0:3] OF INTEGER
- List — in Python, a collection that can contain different data types and does not require a fixed size. Example: A list can grow or shrink as needed.
Exam Tips
Key Definitions to Remember
- An array is a data structure that stores multiple items of the same data type.
- An index is a unique storage slot for each element in an array.
- A 1-Dimensional array is a simple list of items.
- A 2-Dimensional array is a table structure, or arrays within an array.
- A list in Python can contain different data types and does not require a fixed size.
Common Confusions
- Confusing arrays with lists in Python, as lists can store different data types and are not fixed in size.
- Forgetting that arrays have a fixed size and must be defined during declaration.
Typical Exam Questions
- What is an array? An array is a data structure that stores multiple items of the same data type using index numbers.
- How do you access an element in an array? Use the array name followed by the index number, e.g., fruits[2] for 'Strawberry'.
- What is the difference between a 1-D and a 2-D array? A 1-D array is a simple list, while a 2-D array is a table structure with arrays within an array.
What Examiners Usually Test
- Understanding of how to declare and initialize arrays.
- Ability to differentiate between arrays and lists in Python.
- Knowledge of accessing and modifying elements within arrays.