wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

APCSP Unit 2 Review

Total questions: 38

Worksheet time: 2hrs 35mins

Name
Class
Date
1.

Consider the above code segment that is designed to print all numbers from a list of integer values, called grades, that are between 90 and 100, inclusive.


Which of the following modifications can be made to the code to allow it to also print numbers from a variety of different ranges of values (e.g., 70 to 80, 85 to 95, 1 to 50, etc.)?

a)

userPassword = "swordfish"

b)

"swordfish"

c)

userPassword != "swordfish"

d)

userPassword ← INPUT

2.

A large office building has an elevator that carries occupants between any of the building's 10 floors. The basement is referred to as "Level 0" while the topmost floor is "Level 9." The software for the elevator uses a variable, called level, to track the floor number of the elevator's current position. When a person presses a button requesting the elevator to rise to a higher floor, the above code is executed.


What is displayed if the elevator is currently on the 7th floor (level = 7) and the person on the elevator presses a button that says to go up 3 floors (floors = 3)?

a)

Level 7 Level 8 Level 9

b)

Level 8 Level 9 Cannot go up. Level 9

c)

Level 8 Level 9 Level 10

d)

Cannot go up.

3.

Consider the above code segments designed to find the area of a triangle (A = 1/2 bh).


Which of the following statements about the above programs is true?

a)

Both programs will work as intended, but Program B is more readable.

b)

Program A will work as intended, but Program B will not work as intended.

c)

Program B will work as intended, but Program A will not work as intended.

d)

Neither program will work as intended.

4.

Given the above code segment, what would be displayed if age were initialized with a value of 18?

a)

group 1

b)

group 2

c)

group 1 group 2

d)

Nothing will be displayed

5.

What condition will make the above an infinite loop?

a)

y = -108

b)

y≠-3

c)

y ≥ 8

d)

y < -53

6.

The volume of a rectangular prism is calculated by multiplying its length, width and height. What could be substituted into the section of the code marked < missing code > that would accurately calculate the volume based on the user input of l, w and h?

a)

l x w x h

b)

l * w * h

c)

l(w)(h)

d)

l / w / h

7.

What value does the above code segment display?

a)

17

b)

36

c)

53

d)

No value is ever displayed because the algorithm repeats the REPEAT UNTIL block indefinitely.

8.

Consider the above procedure. Which of the following best describes the behavior of the find procedure?

a)

Displays the position of the first occurrence of target in list

b)

Displays the positions of all occurrences of target in list

c)

Displays the position of the last occurrence of target in list

d)

Displays each item in list that is equal to target

9.

In order to be inducted into a school’s National Honor Society (NHS), they must meet certain criteria for their GPA, serviceHours and grade. The expression below indicates whether a student has been accepted as a member of the NHS.


(GPA = 3.65) AND (serviceHours = 30) AND (NOT grade = 9)


Which of the following values would indicate a student that would be accepted into NHS?

a)

GPA = 3.85, serviceHours = 45, grade = 9

b)

GPA = 3.50, serviceHours = 100, grade = 10

c)

GPA = 4.00, serviceHours = 15, grade = 11

d)

GPA = 3.65, serviceHours = 30, grade = 12

10.

Which of the following are benefits of using well-named variables in a computer program?

Select two answers.

a)

The program will run faster.

b)

The program will be easier for people to read.

c)

The program will have a greater data storage capacity.

d)

The program will be easier to modify in the future.

11.
a)
0
b)
9
c)
10
d)
11
12.

Which lines contain the predicates in this script? (Look at the line numbers to the left of the blocks)

a)

lines 2 and 11

b)

lines 2 and 10

c)

lines 4, and 6

d)

lines 8 and 12

13.
Why won't this code continuously move the sprite when clicking the directional arrows?
a)
The "if" statements need to be inside a "forever" block
b)
The "point in directions" values need to change
c)
The "move 1 steps" commands need to be inside a "forever" block
d)
Need a 2nd "point in direction" block after "move 1 step"
14.

The blue "touching" statement uses a Boolean value to create a(n) ...

a)

conditional statement

b)

iteration

c)

loop

d)

algorithm

15.

What will happen when the sprite is clicked?

a)

The sprite will move for 10 steps.

b)

The sprite will move for 8 steps.

c)

The sprite will move for 80 steps.

16.

The script variables in this code are also known as...

a)

global variables

b)

local variables

c)

predicate values

d)

booleans

17.

What is the length of this list?

a)

1

b)

4

c)

5

d)

6

18.

What is the index of "iPhone 7"?

a)

1

b)

4

c)

5

d)

6

19.

True or False: wishList contains Jordan.

a)

True

b)

False

20.

What will wishList look like after pressing the button on the left?

a)

["XBox", "Playstation", "iPhone 7"]

b)

["XBox", "Playstation", "Nintendo Switch", "iPhone 7"]

c)

["XBox", "Playstation", "Nintendo Switch", "Jordans", "iPhone 7"]

d)

["Jordans"]

21.

Which block is used to get "Roussef" from this list?

a)
b)
c)
d)
22.

Which of these behaviors have only been observed in humans?

a)

fainting from fright

b)

mourning & burying the dead

c)

creating & using tools

d)

culture (teaching others languages, behaviors)

23.

Type a number (a numeral): What is the length of this list?

(a)  

24.

What will this report?

a)

4:45, 7:30, 10:15

b)

9:15

c)

[9:15]

d)

[4:45, 7:30, 10:15]

25.

What will this report?

a)

"Copenhagen"

b)

[Copenhagen]

c)

"Ecuador"

d)

[Ecuador]

26.

Type a number (a numeral): What is the length of this list?

(a)  

27.

What will this report?

a)

the whole list

b)

"take out the trash"

c)

[take out the trash]

d)

[eggs, cucumbers, juice, bread]

28.

What will this report?

a)

"math assignment"

b)

"bread"

c)

"b"

d)

error

29.

What will this report?

a)

True

b)

False

30.

What will this report?

a)

True

b)

False

31.

What will this report?

a)

"team practice"

b)

"bread"

c)

"t"

d)

error

32.

True or False? Reports the word "Augusta"

a)

True

b)

False

33.

True or False? set block is run first.

"item 1" block will report two items: "Augusta" and "Maine".

a)

True

b)

False

34.

True or False? "set" block is run first. The item block will report a list of one item, the word "Idaho".

a)

True

b)

False

35.

True or False? Reports the word "Iowa".

a)

True

b)

False

36.

What type of logic operator is this table showing:

a)

AND

b)

OR

c)

NOT

d)

XOR

37.

What type of logic operator is this table showing:

a)

AND

b)

OR

c)

NOR

d)

XOR

38.

What type of logic operator is this table showing:

a)

AND

b)

OR

c)

NOT

d)

NOR