teach-ict.com logo

THE education site for computer science and ICT

1. Introduction to Arrays

An array is a particular type of list data structure - we have a section on lists HERE. An array is used to store related data that are of the same type.

For example, say you wanted to store the names of players in a football team.

One way, is to store the names as independent variables,

Like this:

               player1 = "John Salisbury"

               player2 = "Harold Cooper"

               player3 = "James March"
                 ... and so on

With eleven players on the team, there would be eleven variables. The problem with this is it does not show that there is relationship between the names - that they are all part of the same football team. This is why arrays are useful - they allow you to store related data items as a group.

 

image