WorksheetsCS Python Fundamentals Test 9 PRACTICE
Total questions: 20
Worksheet time: 25mins
When referring to two-dimensional lists, the phrase row-major means
more rows than columns
row first, then column
many rows, only one column
the rows are sorted, the columns are not
Click on the location [1][3] within the 2-D array shown here.
Click on the location [2][2] within the 2-D array shown here.
Based on your understanding of a row-major list in Python, how would a language process a column-major list?
The list would be limited to one row
The first index would be the column; the second index the row
The element at [0][0] would refer to the last value in the list
The row indexes decrease as the column indexes increase
Which of the following statements about lists is false?
An element is the data stored in a specific location
An index is a pointer to a specific location
List row and column numbers begin with 0
The first index in a 2-D list gives the column number
Which line of code correctly declares and initializes a 2-D list in Python?
prime = [2,3], [5,7]
prime = [2,3] + [5,7]
prime = [2,3][5,7]
prime = [[2,3], [5,7]]
Given the code shown here, what are the dimensions of the list? (rows by columns)
4x3
3x2
2x3
3x4
Given the code shown here, what is the output?
23
62
58
61
When this code executes, how many rows does the 2-D list contain?
2
3
4
5
Given the code shown here, what is output?
18
11
13
20
Which of the following statements about 2-D lists is false?
2-D list elements must be the same data type
2-D lists can be traversed with either standard or enhanced for loops
Numerical calculations on 2-D lists require two loops
2-D lists can be traversed backwards (end to beginning)
The code shown here represents a 4x2 list. After the code executes, what does the list contain?
00
11
22
33
01
12
23
34
11
22
33
44
12
23
34
45
Which function correctly swaps the elements of two rows within a 2-D list?
Assume that you have an existing 3x4 2-D list (3 row and 4 columns).
Which algorithm would change the list to match the grid shown here?
Assume that you have an existing 4x5 2-D list (4 rows and 5 columns).
Which algorithm would change the list to match the grid shown here?
Consider the following two-dimensional list.
Which algorithm correctly adds up the values in the second column?
(beginning with 21)?
Which of the following algorithms would correctly initialize and print a 5x7 2-D list of random 3-digit numbers?
Consider the 2-D list shown here. What position is 32 located at?
Your answer should be in this format: [row][col]
(a)
How many rows and columns does this list have?
3 rows and 3 columns
3 rows and 4 columns
4 rows and 3 columns
4 rows and 4 columns
Which is the best definition of a global variable?
A variable that is used in the main part of the program, but not in functions
A variable that is declared inside of a function, but can be used in the main part of the program
A variable that is passed from one function to another as an argument
A variable that is declared in the main part of the program, then re-declared in any function that needs to use it
