wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSP Unit 6

Total questions: 20

Worksheet time: 22mins

Name
Class
Date
1.

the process of accessing each item in a list one at a time

a)

Traversal

b)

Iteration

c)

Selection

d)

Sorting

2.

What is a List in the context of programming?

a)

An unordered collection of elements.

b)

An ordered collection of elements.

c)

A type of variable that can hold only one value.

d)

A method for sorting data.

3.

A counting variable to set an initial value, a Boolean expression, and a statement that increases or decreases the variable being checked are all parts of a(n) _______

a)

Loop

b)

Function

c)

Condition

d)

Array

4.

An individual item in a list that is assigned a unique index....

a)

Element

b)

Node

c)

Attribute

d)

Value

5.

The first item in a list has an index of .....

a)

-1

b)

1

c)

0

d)

2

6.

What does the ++ command do?

a)

Adds 1 to the count

b)

Subtracts 1 from the count

c)

Multiplies the count by 2

d)

Divides the count by 2

7.

The program is designed to determine the minimum value in a list of positive numbers called numList. Which of the following can be used to replace <MISSING CODE> so that the program works as intended for every possible list of positive numbers?

a)

0

b)

1000000

c)

numList.length

d)

numList[0]

8.

myList = [5, 3, 12, 7, 19, 20, 23]. myList.length will return a value of ___

a)

5

b)

6

c)

7

d)

8

9.

Which of the following programs will result in filteredNames only containing the names of students who are 17 or older?

a)

const filteredNames = students.filter(student => student.age >= 17).map(student => student.name);

b)

const filteredNames = students.filter(student => student.age < 17).map(student => student.name);

c)

const filteredNames = students.map(student => student.name).filter(name => name.length > 3);

d)

const filteredNames = students.filter(student => student.age === 17).map(student => student.name);

10.

An ordered collection of elements is a....

a)

List

b)

Array

c)

Set

d)

Dictionary

11.

When the Boolean expression becomes false, the loop ______.

a)

Ends

b)

Continues

c)

Pauses

d)

Restarts

12.

Which of the following is NOT a possible combination of values of the variables in this program when it finishes running?
tails has a value of 0 and heads has a value of 100,
tails has a value of 100 and heads has a value of 0,
tails has a value of 20 and heads has a value of 20,
tails has a value of 50 and heads has a value of 50

a)

tails has a value of 20 and heads has a value of 20

b)

tails has a value of 0 and heads has a value of 100

c)

tails has a value of 100 and heads has a value of 0

d)

tails has a value of 50 and heads has a value of 50

13.

How do you create a list?

a)

By creating a variable and using brackets.

b)

By using a loop to iterate through elements.

c)

By defining a function that returns a list.

d)

By importing a list module from a library.

14.

myList = [9, 10, 11, 12, 13, 14]. What commands are needed to find the average of my list?

a)

Sum, count, average

b)

Total, length, mean

c)

Add, divide, average

d)

Sum, size, median

15.

A common method for referencing the elements in a list using numbers

a)

index

b)

pointer

c)

reference

d)

address

16.

Which line will result in the list containing the values ["air", "rock", "air"]?

a)

wordList[0] = wordList[2]

b)

wordList[2] = wordList[0]

c)

insertItem(wordList, 0, "air")

d)

removeItem(wordList, 0)

17.

What will be displayed in the console when the following program runs? Options: 0 2 4 6, 0 2 4, 2 4 6, The program will result in an infinite loop.

a)

0 2 4 6

b)

0 2 4

c)

2 4 6

d)

The program will result in an infinite loop.

18.

What will the following program display in the console? Options: 0, 5, 10, 15

a)

0

b)

5

c)

10

d)

15

19.

a repetitive portion of an algorithm which repeats a specified number of times or until a given condition is met.

a)

Recursion

b)

Iteration

c)

Selection

d)

Function

20.

What will be displayed in the console when this program runs? Options: 2, 3, 20, 30

a)

2

b)

3

c)

20

d)

30