wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSP Unit 6 -#2

Total questions: 20

Worksheet time: 17mins

Name
Class
Date
1.

The value that is assigned in any list is considered...

a)

Element

b)

Index

c)

String

d)

Integer

2.

Lists reference their values by using which of the following?

a)

Index

b)

Element

c)

Variables

d)

Loops

3.

If I want to place a new element anywhere in a list, I would use which of the following methods?

a)

appendItem

b)

insertItem

c)

addItem

d)

joinItem

4.

What is the output of word1?

var word="APComputerScience";

var word1=word.substring(2,word.length-7);

(a)  

5.

When creating lists, sometimes you will need to create a “scrolling pattern”. 

Which of the following will not scroll beyond the end of a list?

a)

if  (index < myList.length-1) {

Index++

}

b)

if  (index > myList.length-1) {

Index++

}

c)

if  (index < myList.length) {

Index++

}

d)

if  (index > myList.length) {

Index++

}

6.

Which of the following programming constructs is an example of an iteration?

a)

Lists

b)

Loops

c)

Functions

d)

Conditionals

7.

Which of the following is a benefit of using a simulation instead of an experiment to make a prediction?

a)

A simulation produces results that are more accurate than experimental results.

b)

A simulation always produces the same output, so its results can be verified.

c)

A simulation can be used to model real-world events that are impractical for experiments.

d)

A simulation allows investigation of a phenomenon without the real-world limitations on time, safety, or budget.

8.

The process of accessing every item in a list is considered which of the following?

a)

for Loops

b)

traversals

c)

while Loops

d)

appendItems

9.

A school is developing a program to keep track of information about students and their class schedules. In which of the following instances would data abstraction be most helpful?

a)

The program includes individual variables to store the names of each student rather than a single list of students.

b)

A program includes multiple comments that could be combined into a single comment

c)

A program includes repeated programming statements that could be moved inside a loop

d)

A program includes repeated code that could be moved inside a function.

10.

wordList is a list of words that currently contains the values ["tree", "rock", "air"].

Which of the following lines 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)

11.

A 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]

12.

What is displayed as a result of executing the code segment?

a)

true false false

b)

true false true

c)

true true false

d)

true true true

13.

Code segment is intended to move the robot to the gray square.

<MISSING STATEMENT>

{

REPEAT 4 TIMES {

MOVE_FORWARD()

ROTATE_RIGHT() }

ROTATE_LEFT()

MOVE_FORWARD()

ROTATE_RIGHT()

}

a)

REPEAT 1 TIMES

b)

REPEAT 2 TIMES

c)

REPEAT 3 TIMES

d)

REPEAT 4 TIMES

14.

What are the values of count1 and count2 as a result of executing the code segment?

a)

count1 = 2, count2 = 2

b)

count1 = 2, count2 = 3

c)

count1 = 3, count2 = 2

d)

count1 = 5, count2 = 0

15.

Code segment is intended to store ten consecutive even integers, beginning with 2, in the list evenList. Assume that evenList is initially empty.

Which of the following can be used to replace <MISSING CODE>?

a)

APPEND(evenList, i)

i ←← i + 2

b)

i ←← i + 2

APPEND(evenList, i)

c)

APPEND(evenList, 2 * i)

i ←← i + 1

d)

i ←← i + 1

APPEND(evenList, 2 * i)

16.

In a certain game, a player may have the opportunity to attempt a bonus round to earn extra points. In a typical game, a player is given 1 to 4 bonus round attempts. For each attempt, the player typically earns the extra points 70% of the time and does not earn the extra points 30% of the time.

Which of the following is NOT a possible output of this simulation?

a)

The player had 1 bonus round attempts and 1 of them earned extra points.

b)

The player had 2 bonus round attempts and 0 of them earned extra points.

c)

The player had 3 bonus round attempts and 7 of them earned extra points.

d)

The player had 4 bonus round attempts and 3 of them earned extra points.

17.

The transportation department plans to build a new high-speed train route between two cities. The transportation department wants to implement a simulation of the train before any construction begins on this project. Which of the following statements is true about the use of a simulation for this project?

a)

A simulation cannot be used to test the train under varying weather conditions.

b)

Implementing a simulation is likely to increase the overall costs associated with the project.

c)

Other high-speed train routes have been constructed in other locations, so a simulation is not needed.

d)

Using a simulation may expose potential safety issues that can be corrected before construction begins.

18.

In which of the following scenarios would a simulation be the LEAST beneficial?

a)

An engineering company wants to test whether a change to a car design will negatively affect fuel efficiency.

b)

An insurance company wants to study the effect of cold weather patterns on health-care costs.

c)

A manufacturing company wants to determine whether using robots in its facility will increase productivity.

d)

A retail company wants to determine the most popular item that was sold on the company’s Web site last month.

19.

A spinner contains 12 regions of equal size. The regions are numbered 1 to 12. Which of the following code segments can be used to simulate the results of spinning the spinner three times and assigns the sum of the values obtained by the three spins to the variable sum ?

a)

sum ←← RANDOM(1, 12) + RANDOM(1, 12) + RANDOM(1, 12)

b)

sum ←← RANDOM(1, 36)

c)

sum ←← 3 * RANDOM(1, 12)

d)

sum ←← 12 * RANDOM(1, 3)

20.

What will be displayed in the console when the following program runs?

a)

0 2 4 6

b)

0 2 4

c)

2 4 6

d)

The program will result in an infinite loop