wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CS Python Fundamentals Test 9 PRACTICE

Total questions: 20

Worksheet time: 25mins

Name
Class
Date
1.

When referring to two-dimensional lists, the phrase row-major means

a)

more rows than columns

b)

row first, then column

c)

many rows, only one column

d)

the rows are sorted, the columns are not

2.

Click on the location [1][3] within the 2-D array shown here.

3.

Click on the location [2][2] within the 2-D array shown here.

4.

Based on your understanding of a row-major list in Python, how would a language process a column-major list?

a)

The list would be limited to one row

b)

The first index would be the column; the second index the row

c)

The element at [0][0] would refer to the last value in the list

d)

The row indexes decrease as the column indexes increase

5.

Which of the following statements about lists is false?

a)

An element is the data stored in a specific location

b)

An index is a pointer to a specific location

c)

List row and column numbers begin with 0

d)

The first index in a 2-D list gives the column number

6.

Which line of code correctly declares and initializes a 2-D list in Python?

a)

prime = [2,3], [5,7]

b)

prime = [2,3] + [5,7]

c)

prime = [2,3][5,7]

d)

prime = [[2,3], [5,7]]

7.

Given the code shown here, what are the dimensions of the list? (rows by columns)

a)

4x3

b)

3x2

c)

2x3

d)

3x4

8.

Given the code shown here, what is the output?

a)

23

b)

62

c)

58

d)

61

9.

When this code executes, how many rows does the 2-D list contain?

a)

2

b)

3

c)

4

d)

5

10.

Given the code shown here, what is output?

a)

18

b)

11

c)

13

d)

20

11.

Which of the following statements about 2-D lists is false?

a)

2-D list elements must be the same data type

b)

2-D lists can be traversed with either standard or enhanced for loops

c)

Numerical calculations on 2-D lists require two loops

d)

2-D lists can be traversed backwards (end to beginning)

12.

The code shown here represents a 4x2 list. After the code executes, what does the list contain?

a)

00

11

22

33

b)

01

12

23

34

c)

11

22

33

44

d)

12

23

34

45

13.

Which function correctly swaps the elements of two rows within a 2-D list?

a)

b)

c)

d)

14.

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?

a)
b)
c)
d)
15.

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?

a)
b)
c)

d)

16.

Consider the following two-dimensional list.

Which algorithm correctly adds up the values in the second column?

(beginning with 21)?

a)

b)

c)

d)

17.

Which of the following algorithms would correctly initialize and print a 5x7 2-D list of random 3-digit numbers?

a)

b)

c)

d)

18.

Consider the 2-D list shown here. What position is 32 located at?

Your answer should be in this format: [row][col]

(a)  

19.

How many rows and columns does this list have?

a)

3 rows and 3 columns

b)

3 rows and 4 columns

c)

4 rows and 3 columns

d)

4 rows and 4 columns

20.

Which is the best definition of a global variable?

a)

A variable that is used in the main part of the program, but not in functions

b)

A variable that is declared inside of a function, but can be used in the main part of the program

c)

A variable that is passed from one function to another as an argument

d)

A variable that is declared in the main part of the program, then re-declared in any function that needs to use it