15 - 1 and 2d Arrays

 1. Read the below paragraph on arrays and fill in the blanks.
Arrays are made up of elements (items) holding items of the same _______________
(note however, that Python lists store different data types can be used as 

Every item in an array has an _________like a room number in a hotel 
that we can access it by. 

Some arrays can have 'multiple floors' in keeping with the hotel analogy. In this 
case we would call them ________________

A scores_array is shown below>>

          0              1              2             3                 4    
         100            90              80           70                 60
scores_array [3] will return ___________

  index / data type / creational / 80

  data type / index / multi-dimensional 70

  index / data type / fictional / 80

  data type / index / one dimensional /70

 2. What is the output of print(scores_array[0] - scores_array[1])?
scores_array shown below>>
          0              1              2             3                 4   
         100            90              80           70                 60

*Note that this is a simple 1d array





 3. A 2d array is used to store the names of the top two pupils in each round of a maths challenge. (e.g. Ruth and Jonathan were the top pupils in the Logic Round, and Hannah and Pigacheen were top two in Mental Maths. Which of the statements below is accurat
Valid reasons for using a 2d array to store this data in this case are:
Option #1 : Multiple items of data need to be stored 

Option #2 : All data being stored has the same data type (String)

Option #3 : Data is split by two categories so can be represented as a table 
            and a table is best represented by a 2d array

Option #4 : The data can be stored together under one variable name. 

Option #5 : Accessing the information would be more efficient if a 2d array 
            is used e.g. a single command could be used to access a 
	        name rather than two
Option #6 : All of the above options are valid

  Option #1 and Option #4

  None of these options describe the advantages of a 2d array

  Option #6

  Option #1 and Option #3

 4. Select the correct answer that corresponds to where the "?" is below.





 5. What would the result of Mynames(2,1) and Mynames(3,0) in this example be?

  Joey / Mention

  Jonathan / Joey

  Smith / Marvin

  Blogs / Joey

 6. What would the output of this print call (referring to the matrix) be?





 7. The below shows the creation of a 2d array to store names in Analyse the algorithm and re-create it in python. What needs to go on line 6? Play around with the 2d array and nested for loops to see how it works!

  for j in range(2): (indented inside the first for loop)

  for j in range(1): (indented inside the first for loop)

  for j in range(3): (indented inside the first for loop)

  for j in range(4): (indented inside the first for loop)

 8. You may want to search for a particular first name, and return the surname. Play around with the code below to return the surname for any specified first name. e.g. if it is 'jonathan', it should print 'marvin'. Can you fill in the missing code?





 9. A teacher wants to record how many hours his three students have spent coding for every day of one week. He stores the data in a 2d array called "codingTime". Fill in the blanks below
                             Days of the week
				0       1         2       3      4      5       6 
Student   0   |  2       3         1       2      1      0       7
	      1   |  1       2         0       2      0      2       5
		  2   |  0       0         1       1      1      1       7

The number of hours coded by student 2 on day 0 is given by:

	>>codingTime[0,2] (which will give) ___________?
Code to display the coding time by student 3 on day 4 would be> ____________?

  1 / [3,4]

  0 / [3][4]

  1 / codingTime[3,4]

  0 / codingTime[4,3]

 10. You are required to write code that takes a student number as an input and then outputs the total number of coding hours that they have completed over the week. Fill in the blank in the trinket below. Extension: add up the total hours.

  it could be: print("Hours for each day of week:",codingTime[0][6])

  it could be: print("Hours for each day of week:",codingTime[student])

  it could be: print("Hours for each day of week:",codingTime[0][1][2])

  it could be: print("Hours for each day of week:",codingTime[i][j])