2D arrays and matrices
Python structure programming
Python - 2-D Array
Two dimensional array is an array within an
array.
It is an array of arrays.
In this type of array the position of an data
element is referred by two indices instead of
one.
Example (1)
Consider the example of recording temperatures 4
times a day, every day.
Accessing Values
Example (2)
Inserting Values
We can insert new data elements at specific position
by using the insert() method and specifying the
index.
Updating Values
We can update the entire inner array or some specific
data elements of the inner array by reassigning the
values using the array index.
Deleting the Values
What is matrix ??
array where
Matrix is a special case of two dimensional
each data element is of strictly same
size. So every matrix is also a two dimensional array but not vice
versa.
Example (3)
Consider the case of recording temperature for 1
week measured in the morning, mid-day, evening and
mid-night. It can be presented as a 7X5 matrix using
an array.
Accessing Values
Adding a row
Adding a column
Delete a row
Delete a column
Update a row