Welcome to the lesson on Python arrays
Arrays
Arrays are basically a much more compact version of lists. However they have to be declared.
declaration can be done by entering import array as arr.
Example: Here , an array is declared.

In this example, an array is declared and then used.
Why arrays then?
It all seems like a huge hoax, arrays not bringing too much to the table. However there are times where an array is preferred to a list.
In cases where millions of data needs to be stored in a collection of data, an array can come in handy to reduce both memory and file size. In cases where calculation needs to be done. An array can come in handy too as lists cannot do direct calculation.
Array methods
These are the table of methods the Array can use.
Method | Description |
---|---|
append() | adds an element at the back of the array. |
clear() | removes all data from the array. |
copy() | returns a copy of the array. |
count() | counts the number of data with a specific value. |
extend() | adds a list to the back of a pre-existing array. |
index() | returns specific index of specified data. |
insert() | inserts data in a specified position. |
pop() | removes a specific data with reference to position. |
remove() | removes a specific data with reference to specified value. |
reverse() | reverses the array's order. |
sort() | sorts a array. |
End of Python Arrays
You have learned Arrays in simple terms. Let's proceed on to Quiz.