Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP CSP Unit 3 Quiz 2 PRACTICE

Total questions: 8

Worksheet time: 14mins

Name
Class
Date
1.

What will be the effect on words, a non-empty list of strings, when the following scratch program is run?

a)

The strings in words will be duplicated so each one appears twice

b)

The order of the strings in words will be reversed

c)

The strings in words will be sorted into alphabetical order

d)

Nothing will change: the list words will be identical to its previous state before the program was run

2.

The contents of list are initially a, b, e. Which of the following code fragments would change the contents of list to be a, b, c, d, e? Select two answers.

a)

b)

c)

d)

3.

Which of the following would not be considered an example of abstraction?

a)

Creating a list of integers named myList and referring to this in the code of a program rather than writing the list each time it is used

b)

Using a procedure (custom block) which swaps the values of two variables input as parameters rather than writing code to swap the blocks each time

c)

Writing machine code rather than using a high-level programming language to program a chip to behave in a certain way

d)

Writing binary numbers to represent the states of various switches and lights in a digital circuit

4.

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of “goats” and “sheep” throughout the text. Consider the programmer’s goal of changing all occurrences of “goats” to “sheep” and all occurrences of “sheep” to “goats.” The programmer will use the fact that the word “foxes” does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish this?

a)

First, change all occurrences of “goats” to “sheep”, and then change all occurrences of “sheep” to “goats”

b)

First, change all occurrences of “goats” to “sheep,” then change all occurrences of “sheep” to “foxes” and then change all occurrences of “foxes” to “goats”

c)

First, change all occurrences of “goats” to “foxes,” then change all occurrences of “sheep” to “goats” and then change all occurrences of “foxes” to “sheep”

d)

First, change all occurrences of “goats” to “foxes,” then change all occurrences of “foxes” to “sheep” and then change all occurrences of “sheep” to “goats”

5.

What would the list moreLetters contain after the following code segment is run?

a)

M, N, O, P, Q

b)

M, N, O, P, Q, A, D

c)

A, M, N, D, O, P, Q

d)

M, N, O, P, Q, A, B, C, D, E

6.

Assuming the list ints contains exactly 10 values, what would happen when the script below is run?

a)

The sprite would say “0”

b)

The sprite would say the item at number 1 on the list ints

c)

The sprite would say the item at number 10 on the list ints

d)

The sprite would say nothing

7.

The procedure EditPlaylist, shown below, is intended to allow a user to edit the contents of the list playlist. Which of the following best describes the behavior of this procedure when it is run and the values 3 and Bohemian Rhapsody are entered in that order? (You may assume that the length of playlist is greater than 4)

a)

The item at index 3 on playlist is replaced with the item Bohemian Rhapsody, and the length of the list does not change

b)

The item Bohemian Rhapsody is inserted at index 3 on playlist and all subsequent items in playlist are shifted one position lower, causing the length of the list to increase by 1

c)

The item at index 3 on playlist is removed, and then the item previously at index 4 (now at index 3) is replaced with the item Bohemian Rhapsody, meaning the length of the list is decreased by 1

d)

No changes are made to the contents of playlist

8.

What value does the following code segment display?

a)

20

b)

26

c)

30

d)

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