MULTIDIMENTIONAL ARRYS
A multidimensional Array is an ‘array of arrays’; which each item at an
index is another array.
Ex : single array
Cars=[‘ford’, ’Mercedes’, ‘Toyota’, ‘BMW’, ‘Audi’]
Ex: Two Dimensional Array examResults
Array declared as array[3,4]
0 1 2 3
0 80 59 34 89
1 31 11 47 64
2 29 56 13 91
• Each item of data has two indexes.
• examResults[1,2]=47
• Array for the Table
Scores=[[80,59,34,89],[31,11,47,64],[29,56,13,91]]
Ex1. A teacher has stored the surnames and test scores of a class
of students in a two-dimentional array. Eg
results[[‘smith’,’69’],[‘jakson’,’90’]].etc.create a program that
would print out the names and test scores of all the students who
have scored 50 or over in test.
results=[['smith',69],['jakson',90],['Dubois',30]]
for index in range(0, len(results)):
if results[index][1] >=50:
print(results[index][0] +” “ + str(results[index][1]))
Activity 17