0% found this document useful (0 votes)
21 views

2D array and Matrix

The document explains the concept of 2D arrays and matrices in Python, highlighting that a 2D array is essentially an array of arrays where data elements are accessed using two indices. It covers operations such as inserting, updating, and deleting values, as well as defining a matrix as a special type of 2D array where all data elements are of the same size. Examples are provided to illustrate how to record and manipulate data using these structures.

Uploaded by

dr.yassin.ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

2D array and Matrix

The document explains the concept of 2D arrays and matrices in Python, highlighting that a 2D array is essentially an array of arrays where data elements are accessed using two indices. It covers operations such as inserting, updating, and deleting values, as well as defining a matrix as a special type of 2D array where all data elements are of the same size. Examples are provided to illustrate how to record and manipulate data using these structures.

Uploaded by

dr.yassin.ashraf
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

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

You might also like