Wednesday 5 February 2014

3.1.2 Arrays

Arrays can also be called Table Arrays.  In Python, you are used to them being called Lists.

Arrays are lists of data that can be accessed by giving an index number.  Remember indexing in computing begins with 0 and goes 1 etc. E.g
studenta = ["Aimee","Jones","10PHD","26/09/2003"] studentb = ["Harry","Moore","10PHD","26/10/2003"] studentc = ["Horrace", "Ransom", "10PHD", "13/10/2013"] studentd = ["Shaniqua", "Tingtongmakadangdang", "10STD", "13/10/1797"]

Adds the students to the students list
students.append(studenta) students.append(studentb) students.append(studentc) students.append(studentd)
print(students[3][1])
so this will print "Shaniqua"


No comments:

Post a Comment