Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1seats[2][0] | ABoth indexes are put in one set of square brackets. Each index needs its own brackets, so use seats[0][1]. | |
| 2board = [["X", "O"], ["O", "X"]] | Brows = len(timetable) | |
| 3Each row of a timetable is an inner list, so len() of the outer list gives the number of rows | CThe row index 2 is out of range because there are only 2 rows, numbered 0 and 1. Use timetable[1][0] to get Art. | |
| 4Change one cell of a game board by giving its row index first, then its column index | Dboard[1][2] = "X" | |
| 5seats = [["Ava", "Liam"], ["Mia", "Noah"]] print(seats[0, 1]) | EGets the element in row 2, column 0 of the seating plan: row index first, then column index | |
| 6timetable = [["Maths", "English"], ["Art", "PE"]] print(timetable[2][0]) | FCreates a 2D array for a game board with 2 rows and 2 columns, as a list of row lists |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
grid[row][col] — A 2D array stores data in rows and columns like a table. Use the row index first, then the column index, to reach one element, such as a seat in a seating plan.grid = [[1, 2, 3], [4, 5, 6]]
print(grid[1][2]) # second row, third columnboard = [["X", "O"], ["O", "X"]]
print(board[0][1
]) # first row, second columnboard = [["-", "-"], ["-", "-"]]
board[1][0] = "X"
print(board)for r in range(len(grid)):
for c in range(len(grid[r])):
print(grid[r][c])board = [["X", "O"], ["O", "X"]]
if board[0][0] == "X":
print("Top left is X")