You can find previous Scholar homework sessions here. Last weeks session was very useful and fits well with recent lessons. I would strongly advise you to put an hour of your time aside and watch the video. Make use of W3 Schools at the same time to practice your forms and PHP.
The next Advanced Higher Computing Science homework session from Scholar will be on Wednesday 11th January. The topic is “HTML Form Processing”, the session starts at 6.30pm.
It took us a little while in class today to remember how 2D arrays work, so I thought I might go over it.
A 2 dimentional (2D) array is an array of arrays. So [[1,2,3,4],[5,6,7,8],[9,10,11,12]] is a 3 item array where each item is a 4 item array. This can be written as
[[1,2,3,4],
[5,6,7,8],
[9,10,11,12]]
You might notice that it looks like a grid (or matrix), this is where the 2D comes in to the name. In python we can create the array and assign it.
2D Array in Python
In the code above you can see the the individual elements of the 2D array are accessed using a pair of square brackets [][]. Using the image below we can see the [1][2] is number 7, as demonstrated in the program above.
We can use a loop to display each value in the 1st column.
Using a for loop with a 2D array.
Or a nested for to display each item in each array