Friday, April 13, 2018

Python - Arrays

PYTHON - ARRAYS


Array is a container which can hold a fix number of items and these items should be of the same type.
Most of the data structures make use of arrays to implement their algorithms.
Following are the important terms to understand the concept of Array.
  • Element− Each item stored in an array is called an element.
  • Index − Each location of an element in an array has a numerical index, which is used to identify the element.

Array Representation

Arrays can be declared in various ways in different languages. Below is an illustration.



As per the above illustration, following are the important points to be considered.

  • Index starts with 0.
  • Array length is 10 which means it can store 10 elements.
  • Each element can be accessed via its index. For example, we can fetch an element at index 6 as 27.