top of page

Data Scientist Program


Free Online Data Science Training for Complete Beginners.

No prior coding knowledge required!

Python Arrays

An array is a special variable, which can hold more than one value at a time. If you have a list of items (a list of student names, for example), storing the students in single variables could look like this:

student1 = "john"
student2 = "jimmy"
student3 = "chris"

but what if you had not 3 students, but 500 and you want to loop through students and find a specific one

An array can hold many values under a single name, and you can access the values by referring to an index number.

Access the Elements of an Array:

ou refer to an array element by referring to the index number.

Get the value of the first array item:
x = student[5]

The Length of an Array:

Use the len() method to return the length of an array (the number of elements in an array).

Return the number of elements in the students array:
x = len(students)

Looping Array Elements :

You can use the for in loop to loop through all the elements of an array.

Print each item in the cars array:
    for x in cars:

Adding Array Elements :

You can use the append() method to add an element to an array.

Add one more element to the cars array:

Removing Array Elements :

You can use the pop() method to remove an element from the array.

Delete the second element of the students array:

Conclusion :

An array is a collection of items stored at contiguous memory locations, and it allows to manipulate a lot of items


Recent Posts

See All


bottom of page