86% found this document useful (7 votes)
25K views108 pages

Ap Computer Science Principles Practice Exam and Notes 2021

Uploaded by

Joseph Petersen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
86% found this document useful (7 votes)
25K views108 pages

Ap Computer Science Principles Practice Exam and Notes 2021

Uploaded by

Joseph Petersen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 108

AP Computer Science

Principles

Practice Exam
and Notes
Effective
2021
© 2021 College Board. College Board, Advanced Placement, AP, AP Central, and the acorn logo are registered
trademarks of College Board.

Visit College Board on the web: collegeboard.org.

2 AP Computer Science Principles Practice Exam


Contents

I. Practice Exam
Exam Content and Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Administering the Practice Exam. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Answer Sheet for Multiple-Choice Section . . . . . . . . . . . . . . . . . . . . . . . 5
AP® Computer Science Principles Practice Exam. . . . . . . . . . . . . . . . . . 6

II. Notes on the Practice Exam


Multiple-Choice Section. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Answer Key and Question Alignment to Course Framework. . . . . . . . 104

Contact Us . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

AP Computer Science Principles Practice Exam 3


Practice Exam

Exam Content and Format


The AP Computer Science Principles Exam consists of the Create performance
task and an end-of-course AP Exam. The Create performance task requires at
least 12 hours of dedicated class time for students to complete. The end-of-course
exam is 2 hours long and includes 70 multiple-choice questions.

Administering the Practice Exam


This section contains instructions for administering the AP Computer Science
Principles Practice Exam. You may wish to use these instructions to create an
exam situation that resembles an actual administration. If so, read the indented,
boldface directions to the students; all other instructions are for administering
the exam and need not be read aloud. Before beginning testing, have all exam
materials ready for distribution. These include test booklets and answer sheets.
(Reminder: Final instructions for every AP Exam are published in the AP Exam
Instructions book.)
When you are ready to begin the exam, say:

You will be given 2 hours to answer 70 multiple-choice questions. Each


question has 4 answer choices.

• For question numbers 1 through 62, mark only the single best answer to
each question.

• For the remaining questions, numbered 131 through 138, mark the two
best answer choices for each question.

Your total score on this multiple-choice exam is based only on the number of
questions answered correctly. Points are not deducted for incorrect answers or
unanswered questions. When you do not know the answer to a question, you
should eliminate as many choices as you can, and then select the best answer
among the remaining choices. If you finish before time is called, you may
check your work.

Programming reference materials are located at the front of the exam.


The reference materials provide instructions and explanations to help you
understand the format and meaning of the questions on the test. As you
encounter programming questions on the test, you should use the reference
materials to clarify the behavior of programming statements found in those
questions.

You have 2 hours for this exam. Open your exam booklet and begin

Note Start Time here______ . Note Stop Time here______ . After 2 hours, say:

Stop working. The exam is over. I will now collect your exam materials.

Collect an exam booklet and answer sheet from each student.

4 AP Computer Science Principles Practice Exam


Name:

AP® Computer Science Principles


Answer Sheet

No. Answer No. Answer No. Answer


1 25 49
2 26 50
3 27 51
4 28 52
5 29 53
6 30 54
7 31 55
8 32 56
9 33 57
10 34 58
11 35 59
12 36 60
13 37 61
14 38 62
15 39
16 40 131
17 41 132
18 42 133
19 43 134
20 44 135
21 45 136
22 46 137
23 47 138
24 48

AP Computer Science Principles Practice Exam 5


AP Computer Science Principles Exam
®

Multiple Choice

DO NOT OPEN THIS BOOKLET UNTIL YOU ARE TOLD TO DO SO.

Instructions
At a Glance
This exam booklet contains 70 multiple-choice questions. Exam reference materials for
Total Time programming questions are located at the beginning of this booklet. As you encounter
2 hours programming questions on the exam, you should use the reference materials to clarify the
Number of Questions behavior of programming statements found in those questions.
70
Percent of Total Score Indicate all of your answers to the multiple-choice questions on the answer sheet. No
70% credit will be given for anything written in this exam booklet, but you may use the booklet
Writing Instrument for notes or scratch work.
Pencil required
Electronic Device
None allowed For questions 1 through 62, select the single best answer choice for each question.

For questions 131 through 138, select the two best answer choices for each question.

Use your time effectively, working as quickly as you can without losing accuracy. Do not
spend too much time on any one question. Go on to other questions and come back to
the ones you have not answered if you have time. It is not expected that everyone will
know the answers to all of the multiple-choice questions.
Your total score on the multiple-choice questions is based only on the number of
questions answered correctly. Points are not deducted for incorrect answers or unanswered
questions.

6
COMPUTER SCIENCE PRINCIPLES
Time — 2 hours
70 Questions

Programming reference materials are included on the following pages. As AP Computer Science Principles does not
designate any particular programming language, these reference materials provide instructions and explanations to help
you understand the format and meaning of the questions you will see on the exam. The reference materials include two
programming formats, text-based and block-based.
Programming instructions use four data types: numbers, Booleans, strings, and lists.
Instructions from any of the following categories may appear on the exam:
• Assignment, Display, and Input
• Arithmetic Operators and Numeric Procedures
• Relational and Boolean Operators
• Selection
• Iteration
• List Operations
• Procedures and Procedure Calls
• Robot

AP Computer Science Principles Practice Exam 7


REFERENCE MATERIALS

Instruction Explanation
Assignment, Display, and Input
Text: Evaluates expression and then assigns a copy
a ← expression of the result to the variable a.
Block:

Text: Displays the value of expression, followed by


DISPLAY(expression) a space.
Block:

Text: Accepts a value from the user and returns the input
INPUT() value.
Block:

Arithmetic Operators and Numeric Procedures


Text and Block: The arithmetic operators +, -, *, and / are
a + b used to perform arithmetic on a and b.
a - b
a * b For example, 17 / 5 evaluates to 3.4.
a / b
The order of operations used in mathematics applies
when evaluating expressions.
Text and Block: Evaluates to the remainder when a is divided
a MOD b by b. Assume that a is an integer greater than or
equal to 0 and b is an integer greater than 0.
For example, 17 MOD 5 evaluates to 2.

The MOD operator has the same precedence as the


* and / operators.
Text: Generates and returns a random integer from a to
RANDOM(a, b) b, including a and b. Each result is equally
likely to occur.
Block:
For example, RANDOM(1, 3) could return 1,
2, or 3.
Relational and Boolean Operators
Text and Block: The relational operators =, ≠, >, <, ≥, and ≤
a = b are used to test the relationship between two
a ≠ b variables, expressions, or values. A comparison
a > b using relational operators evaluates to a Boolean
a < b value.
a ≥ b
a ≤ b For example, a = b evaluates to true if a
and b are equal; otherwise it evaluates to false.

8 AP Computer Science Principles Practice Exam


REFERENCE MATERIALS

Instruction Explanation
Relational and Boolean Operators (continued)
Text: Evaluates to true if condition is false;
NOT condition otherwise evaluates to false.
Block:

Text: Evaluates to true if both condition1 and


condition1 AND condition2 condition2 are true; otherwise evaluates to
false.
Block:

Text: Evaluates to true if condition1 is true


condition1 OR condition2 or if condition2 is true or if both
condition1 and condition2 are true;
Block:
otherwise evaluates to false.

Selection
Text: The code in block of statements is
IF(condition) executed if the Boolean expression condition
{ evaluates to true; no action is taken if
<block of statements> condition evaluates to false.
}
Block:

Text: The code in first block of statements


IF(condition) is executed if the Boolean expression
{ condition evaluates to true; otherwise the
<first block of statements> code in second block of statements is
} executed.
ELSE
{
<second block of statements>
}
Block:

AP Computer Science Principles Practice Exam 9


REFERENCE MATERIALS

Instruction Explanation
Iteration
Text: The code in block of statements is
REPEAT n TIMES executed n times.
{
<block of statements>
}
Block:

Text: The code in block of statements is


REPEAT UNTIL(condition) repeated until the Boolean expression
{ condition evaluates to true.
<block of statements>
}
Block:

List Operations
For all list operations, if a list index is less than 1 or greater than the length of the list, an error message is
produced and the program terminates.
Text: Creates a new list that contains the values
aList ← [value1, value2, value3, ...] value1, value2, value3, and ... at
indices 1, 2, 3, and ... respectively and
Block:
assigns it to aList.

Text: Creates an empty list and assigns it to aList.


aList ← []

Block:

Text: Assigns a copy of the list bList to the list


aList ← bList aList.

Block: For example, if bList contains


[20, 40, 60], then aList will also
contain [20, 40, 60] after the assignment.
Text: Accesses the element of aList at index i.
aList[i] The first element of aList is at index 1 and is
accessed using the notation aList[1].
Block:

10 AP Computer Science Principles Practice Exam


REFERENCE MATERIALS

Instruction Explanation
List Operations (continued)
Text: Assigns the value of aList[i] to the
x ← aList[i] variable x.

Block:

Text: Assigns the value of x to aList[i].


aList[i] ← x

Block:

Text: Assigns the value of aList[j] to aList[i].


aList[i] ← aList[j]
Block:

Text: Any values in aList at indices greater than or


INSERT(aList, i, value) equal to i are shifted one position to the right. The
length of the list is increased by 1, and value is
Block:
placed at index i in aList.

Text: The length of aList is increased by 1, and


APPEND(aList, value) value is placed at the end of aList.
Block:

Text: Removes the item at index i in aList and


REMOVE(aList, i) shifts to the left any values at indices greater than
i. The length of aList is decreased by 1.
Block:

Text: Evaluates to the number of elements in aList.


LENGTH(aList)
Block:

Text: The variable item is assigned the value of each


FOR EACH item IN aList element of aList sequentially, in order, from the
{ first element to the last element. The code in
<block of statements> block of statements is executed once for
} each assignment of item.
Block:

AP Computer Science Principles Practice Exam 11


REFERENCE MATERIALS

Instruction Explanation
Procedures and Procedure Calls
Text: Defines procName as a procedure that takes
PROCEDURE procName(parameter1, zero or more arguments. The procedure contains
parameter2, ...) block of statements.
{
<block of statements> The procedure procName can be called using
} the following notation, where arg1 is assigned
Block: to parameter1, arg2 is assigned to
parameter2, etc.:
procName(arg1, arg2, ...)

Text: Defines procName as a procedure that takes


PROCEDURE procName(parameter1, zero or more arguments. The procedure contains
parameter2, ...) block of statements and returns the value
{ of expression. The RETURN statement may
<block of statements> appear at any point inside the procedure and causes
RETURN(expression) an immediate return from the procedure back to the
} calling statement.
Block: The value returned by the procedure procName
can be assigned to the variable result using the
following notation:
result ← procName(arg1, arg2, ...)

Text: Returns the flow of control to the point where the


RETURN(expression) procedure was called and returns the value of
expression.
Block:

12 AP Computer Science Principles Practice Exam


REFERENCE MATERIALS

Instruction Explanation
Robot
If the robot attempts to move to a square that is not open or is beyond the edge of the grid, the robot will stay
in its current location and the program will terminate.
Text: The robot moves one square forward in the direction
MOVE_FORWARD() it is facing.
Block:

Text: The robot rotates in place 90 degrees


ROTATE_LEFT() counterclockwise (i.e., makes an in-place left turn).
Block:

Text: The robot rotates in place 90 degrees clockwise (i.e.,


ROTATE_RIGHT() makes an in-place right turn).
Block:

Text: Evaluates to true if there is an open square one


CAN_MOVE(direction) square in the direction relative to where the robot is
facing; otherwise evaluates to false. The value
Block:
of direction can be left, right,
forward, or backward.

AP Computer Science Principles Practice Exam 13


Directions: Each of the questions or incomplete statements below is followed by four suggested answers or
completions. Select the one that is best in each case and then enter the letter in the corresponding space on the
answer sheet.

1. Which of the following is an example of a phishing attack?

(A) Loading malicious software onto a user’s computer in order to secretly gain access to sensitive information
(B) Flooding a user’s computer with e-mail requests in order to cause the computer to crash
(C) Gaining remote access to a user’s computer in order to steal user IDs and passwords
(D) Using fraudulent e-mails in order to trick a user into voluntarily providing sensitive information

2. To be eligible for a particular ride at an amusement park, a person must be at least 12 years old and must be
between 50 and 80 inches tall, inclusive.

Let age represent a person’s age, in years, and let height represent the person’s height, in inches. Which
of the following expressions evaluates to true if and only if the person is eligible for the ride?
(A) (age ˛ 12) AND ((height ˛ 50) AND (height ˝ 80))

(B) (age ˛ 12) AND ((height ˝ 50) AND (height ˛ 80))


(C) (age ˛ 12) AND ((height ˝ 50) OR (height ˛ 80))

(D) (age ˛ 12) OR ((height ˛ 50) AND (height ˝ 80))

GO ON TO THE NEXT PAGE.

14 AP Computer Science Principles Practice Exam


3. Consider the following code segment.

What are the values of first and second as a result of executing the code segment?

(A) first = 100, second = 100


(B) first = 100, second = 200
(C) first = 200, second = 100
(D) first = 200, second = 200

4. Which of the following best explains the relationship between the Internet and the World Wide Web?
(A) Both the Internet and the World Wide Web refer to the same interconnected network of devices.
(B) The Internet is an interconnected network of data servers, and the World Wide Web is a network of user
devices that communicates with the data servers.
(C) The Internet is a local network of interconnected devices, and the World Wide Web is a global network that
connects the local networks with each other.
(D) The Internet is a network of interconnected networks, and the World Wide Web is a system of linked pages,
programs, and files that is accessed via the Internet.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 15


5. A code segment is intended to display the following output.
up down down down up down down down
Which of the following code segments can be used to display the intended output?

(A) (B)

(C) (D)

GO ON TO THE NEXT PAGE.

16
6. Which of the following best exemplifies the use of multifactor authentication to protect an online banking
system?

(A) When a user resets a password for an online bank account, the user is required to enter the new password
twice.
(B) When multiple people have a shared online bank account, they are each required to have their own unique
username and password.
(C) After entering a password for an online bank account, a user must also enter a code that is sent to the user’s
phone via text message.
(D) An online bank requires users to change their account passwords multiple times per year without using the
same password twice.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 17


7. A game is played by moving a game piece left or right along a horizontal game board. The board consists of
spaces of various colors, as shown. The circle represents the initial location of the game piece.

Yellow Black Green Green Red Yellow Black Black Yellow Black

The following algorithm indicates how the game is played. The game continues until the game is either won by
landing on the red space or lost when the piece moves off either end of the board.

Step 1: Place a game piece on a space that is not red and set a counter to 0.

Step 2: If the game piece is on a yellow space, move the game piece 3 positions to the left
and go to step 3. Otherwise, if the game piece is on a black space, move the game
piece 1 position to the left and go to step 3. Otherwise, if the game piece is on a
green space, move the game piece 2 positions to the right and go to step 3.

Step 3: Increase the value of the counter by 1.

Step 4: If game piece is on the red space or moved off the end of the game board, the game is
complete. Otherwise, go back to step 2.

If a game is begun by placing the game piece on the rightmost black space for step 1, what will be the value of
the counter at the end of the game?

(A) 2
(B) 3
(C) 4
(D) 5

GO ON TO THE NEXT PAGE.

18
8. Which of the following best describes a direct benefit in using redundant routing on the Internet?

(A) Redundancy enables messages to be transmitted with as few packets as possible.


(B) Redundancy enables network devices to communicate with as few network connections as possible.
(C) Redundancy often allows messages to be sent on the network even if some network devices or connections
have failed.
(D) Redundancy prevents network communications from being intercepted by unauthorized individuals.

9. Which of the following best explains how an analog audio signal is typically represented by a computer?
(A) An analog audio signal is measured as input parameters to a program or procedure. The inputs are
represented at the lowest level as a collection of variables.
(B) An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is
represented at the lowest level as a sequence of bits.
(C) An analog audio signal is measured as a sequence of operations that describe how the sound can be
reproduced. The operations are represented at the lowest level as programming instructions.
(D) An analog audio signal is measured as text that describes the attributes of the sound. The text is
represented at the lowest level as a string.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 19


Questions 10–11 refer to the information below.
The player controls in a particular video game are represented by numbers. The controls and their corresponding
binary values are shown in the following table.
Control Binary Value
˜ 01000
° 01001
˛ 01011
˝ 01111
Jump 11000
Run 11001
Pause 11011
Reset 11111
The numeric values for the controls can also be represented in decimal (base 10).

10. What is the decimal value for the jump control?


(A) 3
(B) 12
(C) 24
(D) 48

11. What control is represented by the decimal value 15 ?


(A) ˜
(B) °
(C) ˛
(D) ˝

GO ON TO THE NEXT PAGE.

20
12. The grid below contains a robot represented as a triangle, initially facing toward the top of the grid. The robot
can move into a white or gray square but cannot move into a black region.

The code segment below uses the procedure goalReached, which evaluates to true if the robot is in the
gray square and evaluates to false otherwise.
REPEAT UNTIL(goalReached())
{
<MISSING CODE>
}
Which of the following replacements for <MISSING CODE> can be used to move the robot to the gray
square?

(A) IF(CAN_MOVE(left)) (B) IF(CAN_MOVE(forward))


{ {
ROTATE_LEFT() MOVE_FORWARD()
MOVE_FORWARD() ROTATE_LEFT()
} }

(C) IF(CAN_MOVE(left)) (D) IF(CAN_MOVE(forward))


{ {
ROTATE_LEFT() MOVE_FORWARD()
} }
MOVE_FORWARD() ELSE
{
ROTATE_LEFT()
}

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 21


13. Which of the following is NOT a benefit of collaborating to develop a computing innovation?

(A) Collaboration can decrease the size and complexity of tasks required of individual team members.
(B) Collaboration can make it easier to find and correct errors during the development process.
(C) Collaboration eliminates the need to resolve differences of opinion.
(D) Collaboration facilitates multiple perspectives in developing ideas.

GO ON TO THE NEXT PAGE.

22
14. A list of numbers is considered increasing if each value after the first is greater than or equal to the preceding
value. The following procedure is intended to return true if numberList is increasing and return
false otherwise. Assume that numberList contains at least two elements.
Line 1: PROCEDURE isIncreasing(numberList)
Line 2: {
Line 3: count ← 2
Line 4: REPEAT UNTIL(count > LENGTH(numberList))
Line 5: {
Line 6: IF(numberList[count] < numberList[count - 1])
Line 7: {
Line 8: RETURN(true)
Line 9: }
Line 10: count ← count + 1
Line 11: }
Line 12: RETURN(false)
Line 13: }
Which of the following changes is needed for the program to work as intended?
(A) In line 3, 2 should be changed to 1.
(B) In line 6, < should be changed to ˛.
(C) Lines 8 and 12 should be interchanged.
(D) Lines 10 and 11 should be interchanged.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 23


15. Consider the following procedure.

Procedure Call Explanation


drawLine(x1, y1, x2, y2) Draws a line segment on a coordinate grid with endpoints at
coordinates (x1, y1) and (x2, y2)
The drawLine procedure is to be used to draw the following figure on a coordinate grid.

Which of the following code segments can be used to draw the figure?

(A) xVal ← 1
yVal ← 0
len ← 1
REPEAT 5 TIMES
{
drawLine(xVal, yVal, xVal, yVal + len)
xVal ← xVal + 1
len ← len + 1
}
(B) xVal ← 1
yVal ← 0
len ← 1
REPEAT 5 TIMES
{
drawLine(xVal, yVal, xVal + len, yVal)
yVal ← yVal + 1
len ← len + 1
}

GO ON TO THE NEXT PAGE.

24
(C) xVal ← 5
yVal ← 0
len ← 5
REPEAT 5 TIMES
{
drawLine(xVal, yVal, xVal, yVal + len)
xVal ← xVal - 1
}

(D) xVal ← 5
yVal ← 0
len ← 5
REPEAT 5 TIMES
{
drawLine(xVal, yVal, xVal + len, yVal)
yVal ← yVal - 1
len ← len - 1
}

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 25


16. The author of an e-book publishes the e-book using a no-rights-reserved Creative Commons license. Which of
the following best explains the consequences of publishing the book with this type of license?

(A) The contents of the e-book will be encrypted and can only be decrypted by authorized individuals.
(B) Individuals can freely distribute or use the contents of the e-book without needing to obtain additional
permissions from the author.
(C) Individuals will be legally prevented from sharing the e-book on a peer-to-peer network.
(D) Individuals will be legally prevented from using excerpts from the e-book in another published work.

GO ON TO THE NEXT PAGE.

26
Questions 17–18 refer to the information below.
The figure below represents a network of physically linked devices labeled A through I. A line between two devices
indicates that the devices can communicate directly with each other.
Any information sent between two devices that are not directly connected must go through at least one other device.
For example, in the network represented below, information can be sent directly between A and B, but information sent
between devices A and G must go through other devices.

17. What is the minimum number of connections that must be broken or removed before device B can no longer
communicate with device C?
(A) Three
(B) Four
(C) Five
(D) Six

18. Which of the following statements is true about the network?


(A) Information sent from device A to device D can use at most two unique paths.
(B) Information sent from device A to device I will pass through at most four other devices.
(C) If devices B and F fail, then device A will not be able to communicate with device G.
(D) If devices C and F fail, then device D will not be able to communicate with device H.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 27


19. Which of the following best explains how devices and information can be susceptible to unauthorized access if
weak passwords are used?

(A) Unauthorized individuals can deny service to a computing system by overwhelming the system with login
attempts.
(B) Unauthorized individuals can exploit vulnerabilities in compression algorithms to determine a user’s
password from their decompressed data.
(C) Unauthorized individuals can exploit vulnerabilities in encryption algorithms to determine a user’s
password from their encryption key.
(D) Unauthorized individuals can use data mining and other techniques to guess a user’s password.

20. A local router is configured to limit the bandwidth of guest users connecting to the Internet. Which of the
following best explains the result of this configuration as compared to a configuration in which the router does
not limit the bandwidth?

(A) The amount of time it takes guest users to send and receive large files is likely to decrease.
(B) The number of packets required for guest users to send and receive data is likely to decrease.
(C) Guest users will be prevented from having fault-tolerant routing on the Internet.
(D) Guest users will be restricted in the maximum amount of data that they can send and receive per second.

GO ON TO THE NEXT PAGE.

28
21. A video-streaming Web site keeps count of the number of times each video has been played since it was first
added to the site. The count is updated each time a video is played and is displayed next to each video to show
its popularity.
At one time, the count for the most popular video was about two million. Sometime later, the same video
displayed a seven-digit negative number as its count, while the counts for the other videos displayed correctly.
Which of the following is the most likely explanation for the error?

(A) The count for the video became larger than the maximum value allowed by the data type used to store the
count.
(B) The mathematical operations used to calculate the count caused a rounding error to occur.
(C) The software used to update the count failed when too many videos were played simultaneously by too
many users.
(D) The software used to update the count contained a sampling error when using digital data to approximate
the analog count.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 29


22. The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in
the center square and facing toward the top of the grid.

The following code segment is used to move the robot in the grid.
count ← 1
REPEAT 4 TIMES
{
REPEAT count TIMES
{
MOVE_FORWARD()
}
ROTATE_LEFT()
count ← count + 1
}
Which of the following code segments will move the robot from the center square along the same path as the
code segment above?
(A) count ← 0 (B) count ← 0
REPEAT 4 TIMES REPEAT 4 TIMES
{ {
count ← count + 1 count ← count + 1
REPEAT count TIMES ROTATE_LEFT()
{ REPEAT count TIMES
MOVE_FORWARD() {
} MOVE_FORWARD()
ROTATE_LEFT() }
} }

(C) count ← 0 (D) count ← 0


REPEAT 4 TIMES REPEAT 4 TIMES
{ {
REPEAT count TIMES ROTATE_LEFT()
{ REPEAT count TIMES
ROTATE_LEFT() {
} MOVE_FORWARD()
MOVE_FORWARD() }
count ← count + 1 count ← count + 1
} }

GO ON TO THE NEXT PAGE.

30
23. Which of the following statements about the Internet is true?

(A) The Internet is a computer network that uses proprietary communication protocols.
(B) The Internet is designed to scale to support an increasing number of users.
(C) The Internet requires all communications to use encryption protocols.
(D) The Internet uses a centralized system to determine how packets are routed.

24. In which of the following situations would it be most appropriate to choose lossy compression over lossless
compression?
(A) Storing digital photographs to be printed and displayed in a large format in an art gallery
(B) Storing a formatted text document to be restored to its original version for a print publication
(C) Storing music files on a smartphone in order to maximize the number of songs that can be stored
(D) Storing a video file on an external device in order to preserve the highest possible video quality

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 31


25. In the following procedure, the parameter n is an integer greater than 2.

Which of the following best describes the value returned by the procedure?
(A) The procedure returns nothing because it will not terminate.
(B) The procedure returns the value of 2 * n.
(C) The procedure returns the value of n * n.
(D) The procedure returns the sum of the integers from 1 to n.

26. Which of the following best describes a challenge involved in using a parallel computing solution?
(A) A parallel computing solution may not be appropriate for an algorithm in which each step requires the
output from the preceding step.
(B) A parallel computing solution may not be appropriate for an algorithm in which the same formula is
applied to many numeric data elements.
(C) A parallel computing solution may not be appropriate for an algorithm that can be easily broken down into
small independent tasks.
(D) A parallel computing solution may not be appropriate for an algorithm that searches for occurrences of a
key word in a large number of documents.

GO ON TO THE NEXT PAGE.

32
27. A certain social media application is popular with people across the United States. The developers of the
application are updating the algorithm used by the application to introduce a new feature that allows users of the
application with similar interests to connect with one another. Which of the following strategies is LEAST
likely to introduce bias into the application?

(A) Enticing users to spend more time using the application by providing the updated algorithm for users who
use the application at least ten hours per week
(B) Inviting a random sample of all users to try out the new algorithm and provide feedback before it is
released to a wider audience
(C) Providing the updated algorithm only to teenage users to generate excitement about the new feature
(D) Testing the updated algorithm with a small number of users in the city where the developers are located so
that immediate feedback can be gathered

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 33


Questions 28–29 refer to the information below.
A flowchart provides a way to visually represent an algorithm and uses the following building blocks.
Block Explanation
Oval The start or end of the algorithm
Rectangle One or more processing steps, such as a statement that assigns a value to a variable
A conditional or decision step, where execution proceeds to the side labeled true if the
Diamond
condition is true and to the side labeled false otherwise
Parallelogram Displays a message
In the flowchart below, assume that j and k are assigned integer values.

28. Which of the following initial values of j and k will cause the algorithm represented in the flowchart to
result in an infinite loop?
(A) j = -5, k = 5
(B) j = 0, k = 5
(C) j = 5, k = 0
(D) j = 5, k = -5

GO ON TO THE NEXT PAGE.

34
29. Based on the algorithm represented in the flowchart, what value is displayed if j has the initial value 3 and
k has the initial value 4 ?

(A) 7
(B) 9
(C) 10
(D) 12

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 35


30. Which of the following best explains how data is transmitted on the Internet?

(A) Data is broken into packets, which are all sent to the recipient in a specified order along the same path.
(B) Data is broken into packets, which can be sent along different paths.
(C) All data is transmitted in a single packet through a direct connection between the sender and the recipient.
(D) Multiple data files are bundled together in a packet and transmitted together.

31. A binary number is to be transformed by appending three 0s to the end of the number. For example, 11101 is
transformed to 11101000. Which of the following correctly describes the relationship between the transformed
number and the original number?

(A) The transformed number is 3 times the value of the original number.
(B) The transformed number is 4 times the value of the original number.
(C) The transformed number is 8 times the value of the original number.
(D) The transformed number is 1,000 times the value of the original number.

GO ON TO THE NEXT PAGE.

36
32. Which of the following is a true statement about the use of public key encryption in transmitting messages?

(A) Public key encryption enables parties to initiate secure communications through an open medium, such as
the Internet, in which there might be eavesdroppers.
(B) Public key encryption is not considered a secure method of communication because a public key can be
intercepted.
(C) Public key encryption only allows the encryption of documents containing text; documents containing
audio and video must use a different encryption method.
(D) Public key encryption uses a single key that should be kept secure because it is used for both encryption
and decryption.

33. A company delivers packages by truck and would like to minimize the length of the route that each driver must
travel in order to reach n delivery locations. The company is considering two different algorithms for
determining delivery routes.
Algorithm I: Generate all possible routes, compute their lengths, and then select the shortest
possible route. This algorithm does not run in reasonable time.

Algorithm II: Starting from an arbitrary delivery location, find the nearest unvisited delivery
location. Continue creating the route by selecting the nearest unvisited location
until all locations have been visited. This algorithm does not guarantee the

shortest possible route and runs in time proportional to n2.

Which of the following best categorizes algorithm II?

(A) Algorithm II attempts to use an algorithmic approach to solve an otherwise undecidable problem.
(B) Algorithm II uses a heuristic approach to provide an approximate solution in reasonable time.
(C) Algorithm II provides no improvement over algorithm I because neither algorithm runs in reasonable time.
(D) Algorithm II requires a much faster computer in order to provide any improvement over algorithm I.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 37


34. In a science experiment, result X is expected to occur 25% of the time and result Y is expected to occur the
remaining 75% of the time. The following code segment is intended to simulate the experiment if there are 100
trials.
Line 1: xCount ← 0
Line 2: yCount ← 0
Line 3: REPEAT 100 TIMES
Line 4: {
Line 5: IF(RANDOM(1, 4) = 1)
Line 6: {
Line 7: xCount ← xCount + 1
Line 8: }
Line 9: IF(RANDOM(1, 4) > 1)
Line 10: {
Line 11: yCount ← yCount + 1
Line 12: }
Line 13: }
Line 14: DISPLAY("Result X occurred")
Line 15: DISPLAY(xCount)
Line 16: DISPLAY("times and result Y occurred")
Line 17: DISPLAY(yCount)
Line 18: DISPLAY("times.")
A programmer runs the code segment, and the following message is displayed.
Result X occurred 24 times and result Y occurred 70 times.
The result shows that 94 trials were counted, rather than the intended 100 trials. Which of the following
changes to the code segment will ensure a correct simulation of the experiment?
(A) Replacing line 9 with IF(RANDOM(1, 4) ˛ 2)
(B) Replacing line 9 with ELSE
(C) Interchanging lines 5 and 9
(D) Interchanging lines 7 and 11

GO ON TO THE NEXT PAGE.

38
35. A city maintains a database of all traffic tickets that were issued over the past ten years. The tickets are divided
into the following two categories.
• Moving violations
• Nonmoving violations
The data recorded for each ticket include only the following information.
• The month and year in which the ticket was issued
• The category of the ticket
Which of the following questions CANNOT be answered using only the information in the database?

(A) Have the total number of traffic tickets per year increased each year over the past ten years?
(B) In the past ten years, were nonmoving violations more likely to occur on a weekend than on a weekday?
(C) In the past ten years, were there any months when moving violations occurred more often than nonmoving
violations?
(D) In how many of the past ten years were there more than one million moving violations?

36. Individuals sometimes attempt to remove personal information from the Internet. Which of the following is the
LEAST likely reason the personal information is hard to remove?

(A) Internet users with a copy of the information might redistribute the personal information without first
seeking permission.
(B) There are potentially an extremely large number of devices on the Internet that may contain the
information.
(C) Automated technologies collect information about Internet users without their knowledge.
(D) All personal information is stored online using authentication measures, making the information hard to
access.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 39


37. In the following code segment, assume that the variable n has been initialized with an integer value.

Which of the following is NOT a possible value displayed by the program?


(A) "artichoke"
(B) "broccoli"
(C) "carrot"
(D) "daikon"

GO ON TO THE NEXT PAGE.

40
38. A scientist wants to investigate several problems. In which of the following situations is using a simulation
LEAST suitable for solving a problem?

(A) When a scientific study requires performing a large number of trials that need to be conducted very quickly
(B) When it is considered acceptable to make simplifying assumptions when modeling a real-world object or
phenomenon
(C) When performing an experiment that would be too costly or dangerous to conduct in the real world
(D) When the solution to the problem requires real-world data inputs that are continually measured at regular
intervals.

39. A store uses binary numbers to assign a unique binary sequence to each item in its inventory. What is the
minimum number of bits required for each binary sequence if the store has between 75 and 100 items in its
inventory?

(A) 5
(B) 6
(C) 7
(D) 8

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 41


40. A state government is attempting to reduce the digital divide. Which of the following activities has the greatest
potential to contribute to the digital divide rather than reducing it?

(A) Providing programs that focus on technology literacy at local libraries


(B) Requiring applicants for government jobs to apply using an online platform
(C) Working with technology companies to offer computing devices at discounted prices to individuals with
reduced incomes
(D) Working with telecommunications companies to build network infrastructure in remote areas

41. An online gaming company is introducing several new initiatives to encourage respectful communication
between players of online games. Which of the following best describes a solution that uses crowdsourcing?
(A) The company allows individual players to endorse fellow players based on courteous interactions. Once a
player receives enough endorsements, the player is given free rewards that can be used during gameplay.
(B) The company eliminates chat from gameplay and sets the default chat policy to off. Players must actively
turn on chat to converse outside of gameplay.
(C) The company introduces software that monitors all chats. Inappropriate conversations are identified, and
players involved in the conversations are banned from the game.
(D) The company updates the acceptable content guidelines to explicitly describe appropriate and
inappropriate behavior. All players must electronically sign an agreement to adhere to the guidelines.

GO ON TO THE NEXT PAGE.

42
42. Consider the following code segment.

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

(A) 3
(B) 4
(C) 9
(D) 12

43. Which of the following best exemplifies the use of keylogging to gain unauthorized access to a computer
system?
(A) A user unintentionally installs a program on their computer that records all user input and forwards it to
another computer. A few weeks later, someone else is able to access the user’s computer using the
recorded data.
(B) A user has a very common password for an online banking account. Someone else guesses the password
after a few attempts and gains access to the user’s account.
(C) A user logs into an unsecure Web site. Someone else is able to view unencrypted log-in information as it is
transmitted over the Internet. The user has the same username and password for multiple accounts, so the
user’s log-in information for multiple systems may be compromised.
(D) A user receives an e-mail that claims to be from the user’s bank. The e-mail instructs the user to click on a
link to a Web site and enter a username and password to verify an account. Shortly after following the
steps, the user discovers that the Web site is fraudulent and that the user’s username and password were
stolen.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 43


44. A program developed for a Web store represents customer account balances using a format that approximates
real numbers. While testing the program, a software developer discovers that some values appear to be
mathematically imprecise. Which of the following is the most likely cause of the imprecision?
(A) The account balances are represented using a fixed number of bits, resulting in overflow errors.
(B) The account balances are represented using a fixed number of bits, resulting in round-off errors.
(C) The account balances are represented using an unlimited number of bits, resulting in overflow errors.
(D) The account balances are represented using an unlimited number of bits, resulting in round-off errors.

GO ON TO THE NEXT PAGE.

44
45. The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially
facing right.

Consider the following procedure.

Which of the following code segments will move the robot to the gray square along the path indicated by the
arrows?
(A) (B)

(C) (D)

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 45


Questions 46–47 refer to the information below.
A large spreadsheet contains the following information about local restaurants. A sample portion of the spreadsheet is
shown below.
C D E
A B
Number of Average Accepts
Restaurant Name Price Range
Customer Ratings Customer Rating Credit Cards
1 Joey Calzone’s Pizzeria lo 182 3.5 false
2 78th Street Bistro med 41 4.5 false
3 Seaside Taqueria med 214 4.5 true
4 Delicious Sub Shop II lo 202 4.0 false
5 Rustic Farm Tavern hi 116 4.5 true
6 ABC Downtown Diner med 0 -1.0 true
• In column B, the price range represents the typical cost of a meal, where "lo" indicates
under $10, "med" indicates $11 to $30, and "hi" indicates over $30.
• In column D, the average customer rating is set to -1.0 for restaurants that have no
customer ratings.

46. A student is developing an algorithm to determine which of the restaurants that accept credit cards has the
greatest average customer rating. Restaurants that have not yet received any customer ratings and restaurants
that do not accept credit card are to be ignored.

Once the algorithm is complete, the desired restaurant will appear in the first row of the spreadsheet. If there are
multiple entries that fit the desired criteria, it does not matter which of them appears in the first row.

The student has the following actions available but is not sure of the order in which they should be executed.

Action Explanation
Filter by number of ratings Remove entries for restaurants with no customer
ratings
Filter by payment type Remove entries for restaurants that do not accept
credit cards
Sort by rating Sort the rows in the spreadsheet on column D
from greatest to least
Assume that applying either of the filters will not change the relative order of the rows remaining in the
spreadsheet.

Which of the following sequences of steps can be used to identify the desired restaurant?
I. Filter by number of ratings, then filter by payment type, then sort by rating
II. Filter by number of ratings, then sort by rating, then filter by payment type
III. Sort by rating, then filter by number of ratings, then filter by payment type

(A) I and II only


(B) I and III only
(C) II and III only
(D) I, II, and III

GO ON TO THE NEXT PAGE.

46
47. A student wants to count the number of restaurants in the spreadsheet whose price range is $30 or less and
whose average customer rating is at least 4.0. For a given row in the spreadsheet, suppose prcRange
contains the price range as a string and avgRating contains the average customer rating as a decimal
number.

Which of the following expressions will evaluate to true if the restaurant should be counted and evaluates to
false otherwise?

(A) (avgRating ˛ 4.0) AND ((prcRange = "lo") AND (prcRange = "med"))


(B) (avgRating ˛ 4.0) AND ((prcRange = "lo") OR (prcRange = "med"))
(C) (avgRating ˛ 4.0) OR ((prcRange = "lo") AND (prcRange = "med"))
(D) (avgRating ˛ 4.0) OR ((prcRange = "lo") OR (prcRange = "med"))

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 47


48. Which of the following is an example of an attack using a rogue access point?

(A) An unauthorized individual gains the ability to view network traffic by connecting to a network router that
uses weak or no security measures.
(B) An unauthorized individual physically disconnects an exposed network router, making the network
unavailable to some users.
(C) An unauthorized individual poses as a network administrator and attempts to trick a user into providing
personal information.
(D) A group of unauthorized individuals overwhelms a network router with traffic, making it unavailable to
some users.

49. Which of the following best explains the ability to solve problems algorithmically?

(A) Any problem can be solved algorithmically, though some algorithmic solutions may require humans to
validate the results.
(B) Any problem can be solved algorithmically, though some algorithmic solutions must be executed on
multiple devices in parallel.
(C) Any problem can be solved algorithmically, though some algorithmic solutions require a very large amount
of data storage to execute.
(D) There exist some problems that cannot be solved algorithmically using any computer.

GO ON TO THE NEXT PAGE.

48
50. Which of the following best explains how symmetric encryption algorithms are typically used?

(A) Symmetric encryption uses a single key that should be kept secret. The same key is used for both
encryption and decryption of data.
(B) Symmetric encryption uses a single key that should be made public. The same key is used for both
encryption and decryption of data.
(C) Symmetric encryption uses two keys that should both be kept secret. One key is used for encryption, and
the other is used for decryption.
(D) Symmetric encryption uses two keys. The key used for encryption should be made public, but the key used
for decryption should be kept secret.

51. Which of the following research proposals is most likely to be successful as a citizen science project?

(A) Collecting pictures of birds from around the world that can then be analyzed to determine how location
affects bird size
(B) Monitoring a group of cells in a laboratory to determine how growth rate is affected by exposure to varying
temperatures
(C) Using a simulation to determine which one from a set of chemicals causes the most significant change to
local animal and plant life
(D) Using specialized equipment to perform three-dimensional scans of complex proteins found in human cells

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 49


52. A sorted list of numbers contains 128 elements. Which of the following is closest to the maximum number of
list elements that can be examined when performing a binary search for a value in the list?

(A) 2
(B) 8
(C) 64
(D) 128

GO ON TO THE NEXT PAGE.

50
53. A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display
true if the value target appears in the list more than once and to display false otherwise. The
algorithm uses the variables position and count. Steps 4 and 5 are missing.
Step 1: Set count to 0 and position to 1.

Step 2: If the value of the element at index position is equal to target, increase
the value of count by 1.

Step 3: Increase the value of position by 1.

Step 4: (missing step)

Step 5: (missing step)

Which of the following could be used to replace steps 4 and 5 so that the algorithm works as intended?
(A) Step 4: Repeat steps 2 and 3 until the value of position is greater than n.
Step 5: If count is greater than or equal to 2, display true. Otherwise, display
false.

(B) Step 4: Repeat steps 2 and 3 until the value of position is greater than n.
Step 5: If count is greater than or equal to position, display true.
Otherwise, display false.

(C) Step 4: Repeat steps 2 and 3 until the value of count is greater than 2.
Step 5: If position is greater than or equal to n, display true. Otherwise,
display false.

(D) Step 4: Repeat steps 2 and 3 until the value of count is greater than n.
Step 5: If count is greater than or equal to 2, display true. Otherwise, display
false.

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 51


54. Delivery trucks enter and leave a depot through a controlled gate. At the depot, each truck is loaded with
packages, which will then be delivered to one or more customers. As each truck enters and leaves the depot, the
following information is recorded and uploaded to a database.
• The truck’s identification number
• The truck’s weight
• The date and time the truck passes through the gate
• Whether the truck is entering or leaving the depot
Using only the information in the database, which of the following questions CANNOT be answered?

(A) On which day in a particular range of dates did the greatest number of trucks enter and leave the depot?
(B) What is the average number of customer deliveries made by each truck on a particular day?
(C) What is the change in weight of a particular truck between when it entered and left the depot?
(D) Which truck has the shortest average time spent at the depot on a particular day?

GO ON TO THE NEXT PAGE.

52
55. A code segment is intended to transform the list utensils so that the last element of the list is moved to the
beginning of the list.

For example, if utensils initially contains ["fork", "spoon", "tongs", "spatula",


"whisk"], it should contain
["whisk", "fork", "spoon", "tongs", "spatula"] after executing the code segment.

Which of the following code segments transforms the list as intended?


(A) len ← LENGTH(utensils)
temp ← utensils[len]
REMOVE(utensils, len)
APPEND(utensils, temp)
(B) len ← LENGTH(utensils)
REMOVE(utensils, len)
temp ← utensils[len]
APPEND(utensils, temp)

(C) len ← LENGTH(utensils)


temp ← utensils[len]
REMOVE(utensils, len)
INSERT(utensils, 1, temp)

(D) len ← LENGTH(utensils)


REMOVE(utensils, len)
temp ← utensils[len]
INSERT(utensils, 1, temp)

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 53


56. Each student at a school has a unique student ID number. A teacher has the following spreadsheets available.
• Spreadsheet I contains information on all students at the school. For each entry in this
spreadsheet, the student name, the student ID, and the student’s grade point average are
included.
• Spreadsheet II contains information on only students who play at least one sport. For each
entry in this spreadsheet, the student ID and the names of the sports the student plays are
included.
• Spreadsheet III contains information on only students whose grade point average is greater
than 3.5. For each entry in this spreadsheet, the student name and the student ID are
included.
• Spreadsheet IV contains information on only students who play more than one sport. For
each entry in this spreadsheet, the student name and the student ID are included.
The teacher wants to determine whether students who play a sport are more or less likely to have higher grade
point averages than students who do not play any sports. Which of the following pairs of spreadsheets can be
combined and analyzed to determine the desired information?

(A) Spreadsheets I and II


(B) Spreadsheets I and IV
(C) Spreadsheets II and III
(D) Spreadsheets III and IV

GO ON TO THE NEXT PAGE.

54
57. A certain computer has two identical processors that are able to run in parallel. The following table indicates the
amount of time it takes to execute each of four processes on a single processor. Assume that none of the
processes is dependent on any of the other processes.

Process Execution Time on


Either Processor
P 30 seconds
Q 10 seconds
R 20 seconds
S 15 seconds
Which of the following parallel computing solutions would minimize the amount of time it takes to execute all
four processes?

(A) Running processes P and Q on one processor and processes R and S on the other processor
(B) Running processes P and R on one processor and processes Q and S on the other processor
(C) Running processes P and S on one processor and processes Q and R on the other processor
(D) Running process P on one processor and processes Q, R, and S on the other processor

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 55


Questions 58–62 refer to the information below.
RunRoutr is a fitness tracking application for smartphones that creates suggested running routes so that users can run
with each other. Upon downloading the application, each user creates a username, a personal profile, and a contact list
of friends who also use the application. The application uses the smartphone’s GPS unit to track a user’s location,
running speed, and distance traveled. Users can use the application to review information and statistics about their
previous runs.
At the beginning of a run, users indicate the distance they want to run from their current location, and the application
suggests a running route. Once a user accepts a suggested route, the application shares the suggested route with other
compatible users in the area so that they can run together. Users are considered compatible if they are on each other’s
contact lists or if they typically run at similar speeds.
A basic RunRoutr account is free, but it displays advertisements that are targeted to individual users based on data
collected by the application. For example, if a user’s running route begins or ends near a particular store, the
application may display an advertisement for that store. Users have the ability to pay a monthly fee for a premium
account, which removes advertisements from the application.

58. Which of the following data must be collected from a user’s smartphone in order for RunRoutr to suggest a
running route?
(A) Available running routes near the user’s home
(B) The current time
(C) The starting location of the user’s previous run
(D) The user’s geographic position

59. Adrianna uses RunRoutr to suggest a running route. All compatible users near Adrianna receive a notification
that shows her running route. Which of the following data is not obtained using data collected from Adrianna’s
smartphone but necessary for RunRoutr to share Adrianna’s running route?

(A) Adrianna’s average running speed


(B) Adrianna’s preferred running distance
(C) The current locations of other RunRoutr users
(D) The usernames on Adrianna’s contact list

GO ON TO THE NEXT PAGE.

56
60. Which of the following is most likely to be a benefit to users of the application?

(A) The application allows users to identify all other users in a particular area.
(B) Users of the application may be able to easily identify all other users in a particular area as a result of the
application’s algorithm for determining whether users are compatible.
(C) Users of the application may see health benefits as a result of the application encouraging them to exercise
with each other.
(D) Users of the application who live in rural areas have the ability to use all the features of the application,
even when they do not have Internet and geolocation connectivity.

61. Which of the following is most likely to be a data privacy concern for RunRoutr users?

(A) Users of the application are required to carry their smartphones with them while running in order to enable
all of the application’s features.
(B) Users of the application may have the ability to determine information about the locations of users that are
not on their contact lists.
(C) Users of the application may not be able to accurately track their running history if they share their
smartphone with another family member.
(D) Users of the application may not be compatible with any other users in their area.

62. Businesses have the ability to target advertisements to different groups of people who use RunRoutr. Which of
the following groups is LEAST likely to receive targeted advertisements?

(A) Individuals who appear on each other’s contact lists


(B) Individuals who are interested in running and fitness
(C) Individuals who sign up for a premium account
(D) Individuals whose running routes begin or end near a particular business location

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 57


Questions 131–138

Directions: For each of the questions or incomplete statements below, two of the suggested answers are correct. For
each of these questions, you must select both correct choices to earn credit. No partial credit will be earned if only one
correct choice is selected. Select the two that are best in each case and then enter the letters in the corresponding
spaces that begin with number 131 on the answer sheet.

131. The following table shows the value of expression based on the values of input1 and input2.

Value of input1 Value of input2 Value of expression


true true false
true false true
false true true
false false true
Which of the following expressions are equivalent to the value of expression as shown in the table?
Select two answers.
(A) (NOT input1) OR (NOT input2)
(B) (NOT input1) AND (NOT input2)
(C) NOT (input1 OR input2)
(D) NOT (input1 AND input2)

GO ON TO THE NEXT PAGE.

58
132. In the following procedure, the parameter age represents a person’s age. The procedure is intended to return
the name of the age group associated with age. People who are under 18 are considered minors, people who
are 65 and older are considered senior citizens, and all other people are considered adults. The procedure does
not work as intended.
Line 1: PROCEDURE ageGroup(age)
Line 2: {
Line 3: result ← "adult"
Line 4: IF(age ˜ 65)
Line 5: {
Line 6: result ← "senior citizen"
Line 7: }
Line 8: RETURN(result)
Line 9:
Line 10: result ← "adult"
Line 11: IF(age < 18)
Line 12: {
Line 13: result ← "minor"
Line 14: }
Line 15: RETURN(result)
Line 16: }
Removing which two lines of code will cause the procedure to work as intended?
Select two answers.
(A) Line 3
(B) Line 8
(C) Line 10
(D) Line 15

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 59


133. Assume that the Boolean variable hot is assigned the value true and the Boolean variable humid is
assigned the value false. Which of the following will display the value true ?

Select two answers.


(A) (B)

(C) (D)

GO ON TO THE NEXT PAGE.

60
134. In a certain video game, players are awarded bonus points at the end of a level based on the value of the integer
variable timer. The bonus points are awarded as follows.
• If timer is less than 30, then 500 bonus points are awarded.
• If timer is between 30 and 60 inclusive, then 1000 bonus points are awarded.
• If timer is greater than 60, then 1500 bonus points are awarded.
Which of the following code segments assigns the correct number of bonus points to bonus for all possible
values of timer ?
Select two answers.

(A) (B)

(C) (D)

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 61


1
135. The following spinner is used in a game. The region labeled "blue" represents of the spinner. The
regions labeled "orange" and "purple" are equal in size. 4

Which of the following code segments can be used to simulate the behavior of the spinner?
Select two answers.

(A) (B)

GO ON TO THE NEXT PAGE.

62
(C) (D)

GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 63


136. The following code segment is intended to remove all duplicate elements in the list myList. The procedure
does not work as intended.
j ← LENGTH(myList)
REPEAT UNTIL(j = 1)
{
IF(myList[j] = myList[j - 1])
{
REMOVE(myList, j)
}
j ← j - 1
}
For which of the following contents of myList will the procedure NOT produce the intended results?

Select two answers.

(A) [10, 10, 20, 20, 10, 10]


(B) [30, 30, 30, 10, 20, 20]
(C) [30, 50, 40, 10, 20, 40]
(D) [50, 50, 50, 50, 50, 50]

137. A group of students take hundreds of digital photos for a science project about weather patterns. Each photo file
contains data representing the level of red, green, and blue for each pixel in the photo. The file also contains
metadata that describes the date, time, and geographic location where the photo was taken. For which of the
following goals would analyzing the metadata be more appropriate than analyzing the data?

Select two answers.


(A) Determining the chronological order of the photos
(B) Determining the number of clouds in a particular photo
(C) Determining whether a photo is suitable for printing in black-and-white
(D) Determining whether two photos were taken at the same location on different days

GO ON TO THE NEXT PAGE.

64
138. The following procedures are available for string manipulation.

Procedure Call Explanation


substring(str, start, end) Returns a substring of consecutive characters of str starting
with the character at position start and ending with the
character at position end. The first character of str is
considered position 1. For example,
substring("delivery", 3, 6) returns "live".
concat(str1, str2) Returns a single string consisting of str1 followed by str2.
For example, concat("key", "board") returns
"keyboard".
len(str) Returns the number of characters in str. For example,
len("key") returns 3.
A programmer wants to create a new string by removing the character in position n of the string oldStr.
For example, if oldStr is "best" and n is 3, then the new string should be "bet". Assume that
1 < n < len(oldStr).
Which of the following code segments can be used to create the desired new string and store it in newStr ?
Select two answers.
(A) left ← substring(oldStr, 1, n - 1)
right ← substring(oldStr, n + 1, len(oldStr))
newStr ← concat(left, right)
(B) left ← substring(oldStr, 1, n + 1)
right ← substring(oldStr, n - 1, len(oldStr))
newStr ← concat(left, right)
(C) newStr ← substring(oldStr, 1, n - 1)
newStr ← concat(newStr, substring(oldStr, n + 1, len(oldStr)))
(D) newStr ← substring(oldStr, n + 1, len(oldStr))
newStr ← concat(newStr, substring(oldStr, 1, n - 1))

STOP

IF YOU FINISH BEFORE TIME IS CALLED, YOU MAY


CHECK YOUR WORK ON THIS TEST.

AP Computer Science Principles Practice Exam 65


Notes on the AP Computer Science
Principles Practice Exam
Multiple-Choice Section
Course Framework Alignment and Rationales

Question 1
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-2.C: Explain how 5.6: Safe
computing based on legal and unauthorized access to Computing
ethical factors. computing resources is
gained.
(A) Incorrect. The act of installing malware on a computer is not in itself a
phishing attack.
(B) Incorrect. Overwhelming a system in an attempt to deny service is not a
phishing attack.
(C) Incorrect. Gaining remote access to a computer is not a phishing attack.
(D) Correct. Phishing is a technique that attempts to trick a user into
providing personal information. In this case, the user is tricked by a
fraudulent e-mail.

Question 2
Skill Learning Objective Topic
Skill 2.B: Implement and apply AAP-2.F.a: For relationships 3.5: Boolean
an algorithm. between Boolean values, Expressions
write expressions using
logical operators.
(A) Correct. For a person to be eligible for the ride, age must be
greater than or equal to 12 and height must be greater than
or equal to 50 and less than or equal to 80. Therefore, all three
of the conditions (age ≥ 12), (height ≥ 50),
and (height ≤ 80) must be true for a person to be eligible
for the ride.
(B) Incorrect. This expression will always evaluate to false because it
is not possible for height to be less than or equal to 50 and also
greater than or equal to 80.
(C) Incorrect. This expression may evaluate to true when the person
is not eligible for the ride. For example, this expression will evaluate to
true when age is 12 and height is 40, even though the
person is not tall enough to be eligible.
(D) Incorrect. This expression may evaluate to true when the person
is not eligible for the ride. For example, this expression will evaluate to
true when age is 11 and height is 55, even though the
person is not old enough to be eligible.

66 AP Computer Science Principles Practice Exam


Question 3
Skill Learning Objective Topic
4.B: Determine the result of AAP-1.B: Determine the 3.1: Variables and
code segments. value of a variable as a result Assignments
of an assignment.
(A) Correct. The variable first is initially assigned the value 100
and the variable second is initially assigned the value 200. Next,
temp is assigned the value of first, which is 100. Next,
second is assigned the value of temp, which is 100. Last,
first is assigned the value of second, which is 100. After
execution, both first and second have the value 100.
(B) Incorrect. The variable second, while initially assigned the value
200, is later assigned the value of temp, which is 100.
(C) Incorrect. The variable first is initially assigned the value 100,
and then later assigned the value of second, which at that point in
the code segment is also 100.
(D) Incorrect. The variable second, while initially assigned the value
200, is later assigned the value of temp, which is 100.
The variable first is initially assigned the value 100, and then
later assigned the value of second, which at that point in the code
segment is also 100.

Question 4
Skill Learning Objective Topic
5.A: Explain how computing CSN-1.D: Describe the 4.1: The Internet
systems work. differences between the
Internet and the World
Wide Web.
(A) Incorrect. The Internet is a network of interconnected networks,
but the World Wide Web is an information system that is accessed
via the Internet.
(B) Incorrect. The Internet is a network of interconnected networks,
but the World Wide Web is an information system that is accessed
via the Internet.
(C) Incorrect. The Internet is a network of interconnected networks,
but the World Wide Web is an information system that is accessed
via the Internet.
(D) Correct. The Internet is the global system of interconnected computer
networks that uses protocols to connect devices worldwide. The World
Wide Web is an information system (of pages, programs, and files) that
is accessible over the Internet.

AP Computer Science Principles Practice Exam 67


Question 5
Skill Learning Objective Topic
2.B: Implement and apply an AAP-2.K.a: For iteration, 3.8: Iteration
algorithm. write iteration statements.
(A) Correct. For each iteration of the outer loop, "up" is displayed once
and then "down" is displayed three times. The outer loop iterates
two times, so "up down down down" is displayed two times
as intended.
(B) Incorrect. This code segment produces the output
"up down down up down down up down down".
(C) Incorrect. This code segment produces the output
"up up up down up up up down".
(D) Incorrect. This code segment produces the output
"up up down up up down up up down".

Question 6
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-2.B: Explain how 5.6: Safe
computing based on legal and computing resources can Computing
ethical factors. be protected and can be
misused.
(A) Incorrect. Users are usually asked to enter a new password twice to help
them avoid making an error when typing a new password. This is not an
example of multifactor authentication.
(B) Incorrect. Having each user of a shared account create a unique
password may help protect the account, but this is not an example of
multifactor authentication.
(C) Correct. Multifactor authentication is a method of computer access
control in which a user is only granted access after successfully
presenting several separate pieces of evidence to an authentication
mechanism. In this case, the user provided a password and showed
evidence of having the phone associated with the user account.
(D) Incorrect. While having users update their password regularly and avoid
reusing old passwords may be helpful in protecting an account, this is
not an example of multifactor authentication.

68 AP Computer Science Principles Practice Exam


Question 7
Skill Learning Objective Topic
2.A: Represent algorithmic AAP-2.J: Express an 3.8: Iteration
processes without using a algorithm that uses
programming language. iteration without using a
programming language.
(A) Incorrect. The counter is incremented once for each time the game
piece moves. The game piece makes four moves before ending in
the red space.
(B) Incorrect. The counter is incremented once for each time the game
piece moves. The game piece makes four moves before ending in t
he red space.
(C) Correct. The game piece begins at the rightmost black space. The
piece moves one space to the left to a yellow space, and the counter
is incremented to 1. The piece then moves three spaces to the left to
another yellow space, and the counter is incremented to 2. The piece
then moves three spaces to the left to a green space, and the counter
is incremented to 3. The piece then moves two spaces to the right to
the red space, and the counter is incremented to 4. The algorithm
terminates now that the piece is in the red space.
(D) Incorrect. The counter is incremented once for each time the game
piece moves. The game piece makes four moves before ending in
the red space.

Question 8
Skill Learning Objective Topic
1.D: Evaluate solution options. CSN-1.E.a: For fault- 4.2: Fault
tolerant systems, like the Tolerance
Internet, describe the
benefits of fault tolerance.
(A) Incorrect. Redundancy on the Internet allows packets to be transmitted
along multiple paths, but does not reduce the number of packets needed
to transmit a particular message.
(B) Incorrect. Redundancy within a system usually requires additional
resources, not fewer. A path within a redundant system may be longer
than the shortest possible path.
(C) Correct. If a particular device or connection on the Internet fails,
subsequent data will be sent via a different route, if possible. This is
supported by redundancy in the network.
(D) Incorrect. Redundancy on the Internet does not protect against
communications being intercepted. Having multiple paths can increase
the number of places that an unauthorized individual can intercept
communications.

AP Computer Science Principles Practice Exam 69


Question 9
Skill Learning Objective Topic
3.C: Explain how abstraction DAT-1.A: Explain how data 2.1: Binary
manages complexity. can be represented using Numbers
bits.
(A) Incorrect. While some programs or procedures take audio data as input,
this is not how audio data are represented digitally. At the lowest level,
all digital data are represented as sequences of bits.
(B) Correct. Analog signals are sampled digitally at discrete intervals over
time. These samples, like all digital data, are represented at the lowest
level as a sequence of bits.
(C) Incorrect. While some programming languages can be used to
manipulate audio data, this is not how audio data are represented
digitally. At the lowest level, all digital data are represented as sequences
of bits.
(D) Incorrect. While some programs transform audio data into text, this
is not how audio data are represented digitally. At the lowest level, all
digital data are represented as sequences of bits.

Question 10
Skill Learning Objective Topic
2.B: Implement and apply an DAT-1.C.a: For binary 2.1: Binary
algorithm. numbers, calculate the Numbers
binary (base 2) equivalent of
a positive integer (base 10)
and vice versa.
(A) Incorrect. The binary equivalent of 3 is 00011.
(B) Incorrect. The binary equivalent of 12 is 01100.
(C) Correct. The binary value 11000 is equal to 24 + 23, which is equal to 24.
(D) Incorrect. The binary equivalent of 48 is 110000.

Question 11
Skill Learning Objective Topic
2.B: Implement and apply an DAT-1.C.a: For binary 2.1: Binary
algorithm. numbers, calculate the Numbers
binary (base 2) equivalent of
a positive integer (base 10)
and vice versa.
(A) Incorrect. The decimal value for ← is equal to 23, or 8.
(B) Incorrect. The decimal value for ↑ is equal to 23 + 20, or 9.
(C) Incorrect. The decimal value for → is equal to 23 + 21 + 20, or 11.
(D) Correct. The decimal number 15 is equal to 23 + 22 + 21 + 20, which
is represented in binary as 01111. Therefore, the decimal value 15
represents the ↓ control.

70 AP Computer Science Principles Practice Exam


Question 12
Skill Learning Objective Topic
2.B: Implement and apply an AAP-2.H.a: For selection, 3.6: Conditionals
algorithm. write conditional
statements.
(A) Incorrect. For each iteration of the loop, if there is an open square to
the left of the robot, this code segment rotates the robot left and then
attempts to move the robot forward one square. The robot does not
have an open square to its left at its initial location; therefore, the code
segment continues in an infinite loop and the robot never moves.
(B) Incorrect. For each iteration of the loop, if there is an open square in
front of the robot, this code segment moves the robot forward one
square and then rotates it left. After the first iteration, the robot has
moved forward one square and has rotated left. For all other iterations,
there is not an open square in front of the robot; therefore, the code
segment continues in an infinite loop and the robot does not make any
additional moves.
(C) Correct. For each iteration of the loop, this code segment rotates the
robot left if there is an open square to its left. Then, whether or not the
robot rotates left, the code segment attempts to move the robot forward
one square. In the first three iterations of the loop, the robot moves
forward three squares from its initial location. In the next iteration of
the loop, it rotates left. In the next three iterations of the loop, it moves
forward three squares. In the next iteration of the loop, it rotates left. In
the last three iterations of the loop, it moves forward three squares to the
gray square at the bottom left corner of the grid.
(D) Incorrect. For each iteration of the loop, this code segment moves
the robot forward if there is an open square in front of the robot.
Otherwise, the robot rotates left. In the first five iterations of the loop,
the robot moves forward five squares to the top of the grid. In the next
two iterations of the loop, the robot rotates left two times. In the next
five iterations of the loop, the robot moves forward five squares to the
bottom of the grid. In the next two iterations of the loop, the robot
rotates left two times. The robot continues in an infinite loop, repeatedly
moving from the bottom of the grid to the top of the grid and back.

AP Computer Science Principles Practice Exam 71


Question 13
Skill Learning Objective Topic
1.C: Explain how collaboration CRD-1.A: Explain how 1.1:
affects the development of a computing innovations Collaboration
solution. are improved through
collaboration.
(A) Incorrect. Collaboration often allows teams to break a complex problem
into smaller parts, decreasing the size and complexity of tasks required
of each team member.
(B) Incorrect. Having multiple team members review components of the
innovation throughout the process can help in the identifying and
correcting errors.
(C) Correct. While effective collaboration often benefits from a diversity of
talents and perspectives, collaborators still need to develop strategies to
resolve differences of opinion.
(D) Incorrect. Effective collaborative teams draw on the diverse perspectives,
skills, and backgrounds of team members.

Question 14
Skill Learning Objective Topic
4.C: Identify and correct errors CRD-2.I.b: For errors in 1.4: Identifying
in algorithms and programs, an algorithm or program, and Correcting
including error discovery correct the error. Errors
through testing.
(A) Incorrect. By making this change, an invalid list index of 0 will be
used. This will not correct the error in the procedure.
(B) Incorrect. By making this change, the procedure will immediately return
true any time it encounters a value that is greater than or equal to the
preceding value. It will not check any subsequent values in the list.
(C) Correct. As is, the procedure traverses numberList from left to
right and returns true whenever it encounters a value that is less
than the preceding value. If it never encounters such a value, false
is returned. This has the effect of returning true whenever the list is
not increasing and returning false whenever the list is increasing,
which is the opposite of what is intended. By interchanging lines 8 and
12, the procedure will return true or false appropriately.
(D) Incorrect. By making this change, an infinite loop will occur if the
second element in the list is greater than or equal to the first element in
the list. In that case, the variable count will never be updated and the
subsequent values in the list will never be checked. This will not correct
the error in the procedure.

72 AP Computer Science Principles Practice Exam


Question 15
Skill Learning Objective Topic
3.B: Use abstraction to manage AAP-3.A.a: For procedure 3.12: Calling
complexity in a program. calls, write statements to call Procedures
procedures.
(A) Correct. This code segment starts at the coordinate (1, 0).
Inside the loop, a call to drawLine draws a vertical line segment
of length len. By increasing xVal by 1 inside the loop, the next
line segment will be drawn one position to the right. By increasing
len by 1 inside the loop, the next line segment drawn will have
its length increased by one. This has the effect of drawing the line
segments shown in the figure from left to right.
(B) Incorrect. This code segment draws five horizontal line segments,
starting with the segment from (1, 0) to (2, 0) and ending
with the segment from (1, 4) to (6, 4).
(C) Incorrect. This code segment draws five vertical line segments that
are all 5 units long, starting with the segment from (5, 0) to
(5, 5) and ending with the segment from (1, 0) to (1, 5).
(D) Incorrect. This code segment draws five horizontal line segments,
starting with the segment from (5, 0) to (10, 0) and ending
with the segment from (5, -4) to (6, -4).

Question 16
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-1.F: Explain how the 5.5: Legal and
computing based on legal and use of computing can raise Ethical Concerns
ethical factors. legal and ethical concerns.
(A) Incorrect. Publishing an e-book with a Creative Commons license does
not encrypt the e-book.
(B) Correct. A no-rights-reserved Creative Commons license is used
when the creator of a published work wants the work to be made freely
available to everyone.
(C) Incorrect. Publishing an e-book with a no-rights-reserved Creative
Commons license enables people to freely distribute it.
(D) Incorrect. Publishing an e-book with a no-rights-reserved Creative
Commons license enables people to freely make use of its content.

AP Computer Science Principles Practice Exam 73


Question 17
Skill Learning Objective Topic
1.D: Evaluate solution options. CSN-1.E.c: For fault- 4.2: Fault
tolerant systems, like Tolerance
the Internet, identify
vulnerabilities to failure in a
system.
(A) Incorrect. Removing any three connections will not prevent devices B
and C from communicating. For example, if connections A-C, C-D,
and B-D are removed, then devices B and C can still communicate along
the path B-E-F-C.
(B) Correct. Devices B and C must be completely cut off from each other
for them to no longer communicate. Removing any three connections
will not prevent devices B and C from communicating. However, if
connections B-A, B-D, B-E, and B-G are removed (or C-A, C-D, C-F,
and C-I), then devices B and C can no longer communicate.
(C) Incorrect. While it is possible to disconnect devices B and C by
removing five connections, it can be done by removing only four
connections.
(D) Incorrect. While it is possible to disconnect devices B and C by
removing six connections, it can be done by removing only four
connections.

Question 18
Skill Learning Objective Topic
1.D: Evaluate solution options. CSN-1.E.c: For fault- 4.2: Fault
tolerant systems, like Tolerance
the Internet, identify
vulnerabilities to failure in a
system.
(A) Incorrect. There are many possible paths between devices A and D,
including A-B-D, A-C-D, A-C-F-D, and A-B-E-F-D.
(B) Incorrect. It is possible for a message to be routed from device A to
device I through more than four other devices. One possible path is
A-B-G-E-H-F-I.
(C) Correct. If devices B and F fail, then devices E, G, and H will become
isolated from devices A, C, D, and I. Therefore, device A will be unable
to communicate with device G.
(D) Incorrect. If devices C and F fail, then device D can still communicate
with device H. One possible path is D-B-E-H.

74 AP Computer Science Principles Practice Exam


Question 19
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-2.B: Explain how 5.6: Safe
computing based on legal and computing resources can Computing
ethical factors. be protected and can be
misused.
(A) Incorrect. Overwhelming a system with requests in order to deny
service can be done regardless of password strength.
(B) Incorrect. Keylogging software can be used to obtain passwords
regardless of password strength.
(C) Incorrect. The exploitation of encryption algorithms is not related to
password strength.
(D) Correct. A strong password is something that is easy for a user to
remember but would be difficult for someone else to guess based on
knowledge of that user. Weak passwords can often be guessed based
on publicly available information about a user. Other weak passwords
(such as "password" or "1234") can often be guessed because they are
commonly used.

Question 20
Skill Learning Objective Topic
5.A: Explain how computing CSN-1.A: Explain how 4.1: The Internet
systems work. computing devices work
together in a network.
(A) Incorrect. Limiting the bandwidth of a connection is likely to increase
the amount of time it takes to send and receive files.
(B) Incorrect. The number of packets used to transmit data is related to the
size of the data, not to the bandwidth of the connection.
(C) Incorrect. Internet routing is fault-tolerant, regardless of the bandwidth
of a local connection.
(D) Correct. The bandwidth of a computer network is the maximum
amount of data that can be sent in a fixed amount of time. With
limited bandwidth, guest users will be restricted in the amount of data
transmitted per second.

AP Computer Science Principles Practice Exam 75


Question 21
Skill Learning Objective Topic
1.D: Evaluate solution options. DAT-1.B: Explain the 2.1: Binary
consequences of using bits Numbers
to represent data.
(A) Correct. This situation is consistent with the behavior of an overflow
error. When the value of the count exceeded the maximum value that
can be represented by a fixed number of bits, the count overflowed and
wrapped around to a negative number.
(B) Incorrect. This situation is consistent with the behavior of an overflow
error, not a rounding error. A rounding error would lead to imprecision
in the count, rather than increasing to the point of wrapping around to a
negative number.
(C) Incorrect. This situation is consistent with the behavior of an overflow
error. If the software used to update the count failed, it would not
increase to the point of wrapping around to a negative number.
(D) Incorrect. This situation is consistent with the behavior of an overflow
error. The count is not an approximation of an analog measurement.

76 AP Computer Science Principles Practice Exam


Question 22
Skill Learning Objective Topic
1.D: Evaluate solution options. AAP-2.L: Compare multiple 3.9: Developing
algorithms to determine Algorithms
if they yield the same side
effect or result.
(A) Correct. The given code segment initializes count to 1 and
increments count at the end of the outer loop. This causes the robot
to move 1 square forward, then rotate left, then move 2 squares forward,
then rotate left, then move 3 squares forward, then rotate left, then move
4 squares forward, then rotate left. The robot ends in the lower-right
corner of the grid, facing toward the top of the grid. This code segment
initializes count to 0 and increments count at the beginning
of the outer loop. Because count is initialized to 0 and then
immediately incremented inside the loop, the inner loop iterates the
same number of times for each iteration of the outer loop as in the given
code segment. The robot ends in the lower-right corner of the grid,
facing toward the top of the grid.
(B) Incorrect. The given code segment causes the robot to end in the lower-
right corner of the grid, facing toward the top of the grid. This code
segment causes the robot to rotate left before moving forward, causing
the robot to follow a different path. The robot ends in the upper-right
corner of the grid, facing toward the top of the grid.
(C) Incorrect. The given code segment causes the robot to end in the lower-
right corner of the grid, facing toward the top of the grid. In this code
segment, since MOVE_FORWARD is outside the inner loop, the robot
moves forward 1 time for each iteration of the outer loop and rotates
left count number of times for each iteration of the inner loop. The
robot ends in the center square of the grid, facing toward the bottom of
the grid.
(D) Incorrect. The given code segment causes the robot to end in the lower-
right corner of the grid, facing toward the top of the grid. In this code
segment, count is 0 in the first iteration of the outer loop, so the
robot rotates left, but does not move forward. The robot ends in the
upper-right corner of the grid, facing toward the top of the grid.

AP Computer Science Principles Practice Exam 77


Question 23
Skill Learning Objective Topic
5.A: Explain how computing CSN-1.B: Explain how the 4.1: The Internet
systems work. Internet works.
(A) Incorrect. The Internet uses standardized, open (nonproprietary)
communication protocols.
(B) Correct. The Internet was designed to be scalable, using open protocols
to easily connect additional computing devices to the network.
(C) Incorrect. The Internet was not designed to be completely secure.
Encryption is not required for communications.
(D) Incorrect. Routing on the Internet is usually dynamic; it is not specified
in advance, nor is it controlled from a central location.

Question 24
Skill Learning Objective Topic
1.D: Evaluate solution options. DAT-1.D: Compare data 2.2: Data
compression algorithms to Compression
determine which is best in a
particular context.
(A) Incorrect. In situations where quality is maximally important, lossless
compression algorithms are typically chosen.
(B) Incorrect. In situations where the ability to reconstruct an original is
maximally important, lossless compression algorithms are typically
chosen.
(C) Correct. In situations where minimizing data size or transmission time
is maximally important, lossy compression algorithms are typically
chosen.
(D) Incorrect. In situations where quality is maximally important, lossless
compression algorithms are typically chosen.

78 AP Computer Science Principles Practice Exam


Question 25
Skill Learning Objective Topic
4.B: Determine the result of AAP-2.K.b: For iteration, 3.8: Iteration
code segments. determine the result or
side effect of iteration
statements.
(A) Incorrect. The procedure will run without error and return a value.
(B) Incorrect. The procedure does not return the value of 2 * n.
For a procedure to return 2 * n, it could initialize result to 0
and then repeatedly add 2 to result a total of n times.
(C) Incorrect. The procedure does not return the value of n * n.
For a procedure to return n * n, it could initialize result to 0
and then repeatedly add n to result a total of n times.
(D) Correct. The procedure initially sets result to 1 and j to 2.
In the REPEAT UNTIL loop, result is first assigned the sum
of result and j, or 1 + 2. The value of j is then increased
to 3. In each subsequent iteration of the loop, result is increased
by each successive value of j (3, 4, 5, etc.) until j exceeds n.
Therefore, the procedure returns the sum of the integers from 1
to n.

Question 26
Skill Learning Objective Topic
1.D: Evaluate solution options. CSN-2.B: Describe benefits 4.3: Parallel
and challenges of parallel and Distributed
and distributed computing. Computing
(A) Correct. The efficiency of a parallel computing solution is limited
by the sequential portion of the solution. If each step is dependent
on the preceding step, then each step must wait for the previous step
to complete before executing. Therefore, the solution is completely
sequential and does not benefit from parallel computing.
(B) Incorrect. If the same formula can be applied to every data element,
then the computations can be done in parallel on multiple processors.
(C) Incorrect. If an algorithm is broken down into small independent tasks,
then each task can be executed in parallel on multiple processors.
(D) Incorrect. Searching for a key word in multiple documents can be
done in parallel, where each processor performs a search on a different
document (or part of a document).

AP Computer Science Principles Practice Exam 79


Question 27
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-1.D: Explain how 5.3: Computing
computing based on legal and bias exists in computing Bias
ethical factors. innovations.
(A) Incorrect. A group of users who use the application at least ten hours
per week is unlikely to be representative of all users of the application.
Using data from only this group may lead to bias.
(B) Correct. Testing the new algorithm on a random sample of users will
help ensure that the data gathered are from a group that is representative
of all users of the application. Gathering data and perspectives from a
representative sample can help the developers avoid bias.
(C) Incorrect. Teenage users are not likely to be representative of all users of
the application. Using data from only this group may lead to bias.
(D) Incorrect. A group of users from only one geographic location is
unlikely to be representative of all users of the application. Using data
from only this group may lead to bias.

Question 28
Skill Learning Objective Topic
2.A: Represent algorithmic AAP-2.J: Express an 3.8: Iteration
processes without using a algorithm that uses
programming language. iteration without using a
programming language.
(A) Incorrect. For these values, -5 will be added to result five times
and -25 will be displayed.
(B) Incorrect. For these values, 0 will be added to result five times
and 0 will be displayed.
(C) Incorrect. For these values, k is initially 0, so the algorithm will
never enter into the loop and 0 will be displayed.
(D) Correct. The value of k is repeatedly decremented by 1 inside
the loop until k = 0. If k is initially negative, it will continue to
decrease without ever reaching 0.

80 AP Computer Science Principles Practice Exam


Question 29
Skill Learning Objective Topic
2.A: Represent algorithmic AAP-2.J: Express an 3.8: Iteration
processes without using a algorithm that uses
programming language. iteration without using a
programming language.
(A) Incorrect. The algorithm in the flowchart calculates the product of j
and k rather than the sum of j and k.
(B) Incorrect. The value 9 represents the result that would be displayed
if the loop iterated one less time.
(C) Incorrect. The value 10 represents the result that would be displayed
if the assignment statement result ← result + j was changed
to result ← result + k.
(D) Correct. The algorithm represented in the flowchart calculates
j * k by repeatedly adding j to result a total of k times.
The value displayed is 12.

Question 30
Skill Learning Objective Topic
5.A: Explain how computing CSN-1.C: Explain how 4.1: The Internet
systems work. data are sent through the
Internet via packets.
(A) Incorrect. Data packets may travel along different paths, arriving at the
destination in order, out of order, or not at all.
(B) Correct. Data transmitted on the Internet is broken into packets and
then reassembled upon arrival. Packets may travel along different paths,
arriving at the destination in order, out of order, or not at all.
(C) Incorrect. Data is broken into packets and then reassembled upon
arrival.
(D) Incorrect. Data is broken into packets and then reassembled upon
arrival.

AP Computer Science Principles Practice Exam 81


Question 31
Skill Learning Objective Topic
2.B: Implement and apply an DAT-1.C.b: For binary 2.1: Binary
algorithm. numbers, compare and Numbers
order binary numbers.
(A) Incorrect. Appending three 0s to the end of a binary number multiplies
it by 23, not by 3.
(B) Incorrect. Appending three 0s to the end of a binary number multiplies
it by 23, not by 4.
(C) Correct. Appending a 0 to the end of a binary number multiplies
the number by 2. Therefore, appending three 0s to the end of a binary
number multiples the number by 2 three times, which is the same as
multiplying the number by 8.
(D) Incorrect. Appending three 0s to a decimal number multiplies it by
1,000. Appending three 0s to the end of a binary number multiplies
it by 23.

Question 32
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-2.B: Explain how 5.6: Safe
computing based on legal and computing resources can Computing
ethical factors. be protected and can be
misused.
(A) Correct. Public-key encryption is considered a secure way of encoding
data to prevent unauthorized access.
(B) Incorrect. A public key is used to encrypt messages, while a private key
is used to decrypt messages. Public key encryption is still considered
secure even if a public key is obtained by an unauthorized individual.
(C) Incorrect. Public key encryption can be used to encrypt any type of
digital data.
(D) Incorrect. Public key encryption uses a public key for encryption and a
private key for decryption. Symmetric encryption is a method that uses
a single key for both encryption and decryption.

82 AP Computer Science Principles Practice Exam


Question 33
Skill Learning Objective Topic
1.D: Evaluate solution options. AAP-4.A.b: For 3.17: Algorithmic
determining the efficiency Efficiency
of an algorithm, identify
situations where a heuristic
solution may be more
appropriate.
(A) Incorrect. The problem described is not undecidable, as it is possible to
find an exact solution using algorithm I.
(B) Correct. Algorithm II runs in time proportional to n2 , which is
considered reasonable time because n2 is a polynomial. This is
considered a heuristic approach because it finds an approximate
solution in reasonable time when the technique that finds an exact
solution (algorithm I) does not run in reasonable time.
(C) Incorrect. Algorithm II runs in time proportional to n2, which is
considered reasonable time because n2 is a polynomial.
(D) Incorrect. An algorithm that runs in reasonable time can show
significant improvement over an algorithm that does not run in
reasonable time, even on a slower computer.

Question 34
Skill Learning Objective Topic
4.C: Identify and correct errors CRD-2.I.b: For errors in 1.4: Identifying
in algorithms and programs, an algorithm or program, and Correcting
including error discovery correct the error. Errors
through testing.
(A) Incorrect. An incorrect trial count occurs because there are two calls to
RANDOM for each iteration of the loop instead of one. Replacing line 9
with IF(RANDOM(1, 4) ≥ 2) will not correct this error.
(B) Correct. An incorrect trial count occurs because there are two calls
to RANDOM for each iteration of the loop instead of one. By replacing
line 9 with an ELSE statement, the code segment will increment
xCount approximately 25% of the time and will increment yCount
otherwise.
(C) Incorrect. An incorrect trial count occurs because there are two calls to
RANDOM for each iteration of the loop instead of one. Interchanging
lines 5 and 9 will not correct this error.
(D) Incorrect. An incorrect trial count occurs because there are two calls to
RANDOM for each iteration of the loop instead of one. Interchanging
lines 7 and 11 will not correct this error.

AP Computer Science Principles Practice Exam 83


Question 35
Skill Learning Objective Topic
5.B: Explain how knowledge DAT-2.A: Describe 2.3: Extracting
can be generated from data. what information can be Information
extracted from data. from Data
(A) Incorrect. This information can be determined by counting the total
number of tickets issued each year.
(B) Correct. The database only tracks the month and year that each ticket
was issued. There is no information about whether the tickets were
issued on weekends or weekdays.
(C) Incorrect. This information can be determined by counting the number
of moving and nonmoving violations that occurred each month.
(D) Incorrect. This information can be determined by counting the total
number of moving violations that occurred each year.

Question 36
Skill Learning Objective Topic
5.D: Describe the impact of IOC-2.A: Describe the risks 5.6: Safe
gathering data. to privacy from collecting Computing
and storing personal data
on a computer system.
(A) Incorrect. Personal information found online can be redistributed via
social media posts, e-mail, and other methods.
(B) Incorrect. Personal information found online can be redistributed
via social media posts, e-mail, and other methods. Through this
redistribution, it can end up on a large number of devices.
(C) Incorrect. Search engines, social media sites, and other data aggregators
can automatically collect personal information that is posted online.
(D) Correct. Personal information can be found in a variety of places where
authentication measures may not be used, including social media
sites. Personal information placed online can be collected, aggregated,
distributed, and exploited.

84 AP Computer Science Principles Practice Exam


Question 37
Skill Learning Objective Topic
4.B: Determine the result of AAP-2.I.b: For nested 3.7: Nested
code segments. selection, determine the Conditionals
result of nested conditional
statements.
(A) Incorrect. The string "artichoke" is displayed for values of n
that are greater than 100.
(B) Incorrect. The string "broccoli" is displayed for values of n
that are greater than 10 but less than or equal to 100.
(C) Correct. The string "carrot" can be displayed only when
the expression (n > 10) is false and the expression
(n > 100) is true. If n is not greater than 10, it cannot be
greater than 100, and so "carrot" can never be displayed.
(D) Incorrect. The string "daikon" is displayed for values of n that
are less than or equal to 10.

Question 38
Skill Learning Objective Topic
1.D: Evaluate solution options. AAP-3.F.b: For simulations, 3.16: Simulations
compare simulations with
real-world contexts.
(A) Incorrect. Simulations are well-suited to situations where real-world
events are impractically slow.
(B) Incorrect. Simulations are simplified abstractions of more-complex
objects or phenomena.
(C) Incorrect. Simulations are well-suited to situations where real-world
events are impractically expensive or dangerous.
(D) Correct. Simulations are most useful when real-world events are
impractical. A simulation is unlikely to be appropriate if continuous
real-world data is needed.

AP Computer Science Principles Practice Exam 85


Question 39
Skill Learning Objective Topic
2.B: Implement and apply an DAT-1.C.a: For binary 2.1: Binary
algorithm. numbers, calculate the Numbers
binary (base 2) equivalent of
a positive integer (base 10)
and vice versa.
(A) Incorrect. Using 5 bits will only allow for up to 32 sequences because
25 = 32.
(B) Incorrect. Using 6 bits will only allow for up to 64 sequences because
26 = 64.
(C) Correct. Using 6 bits will only allow for up to 64 sequences because
26 = 64. Using 7 bits will allow for up to 128 sequences because 27 = 128.
Therefore, a minimum of 7 bits are needed.
(D) Incorrect. Using 8 bits will allow for up to 256 sequences because
28 = 256. However, a unique bit sequence can be assigned using only
7 bits because 27 = 128.

Question 40
Skill Learning Objective Topic
5.C: Describe the impact of a IOC-1.C: Describe issues 5.2: Digital
computing innovation. that contribute to the digital Divide
divide.
(A) Incorrect. Some individuals are unable to use computing devices
effectively due to lack of education and experience with these devices.
Offering educational programs focusing on these skills may help reduce
the digital divide for these individuals.
(B) Correct. The digital divide describes the differences in access to
computing devices and the Internet. Requiring job applicants to apply
online serves only individuals who already have access to computing
devices and the Internet. It does not help reduce the divide.
(C) Incorrect. Some individuals lack access to computing devices because
the devices are prohibitively expensive. Offering low-cost devices may
help reduce the digital divide for these individuals.
(D) Incorrect. Some individuals lack access to the Internet due to lack of
network infrastructure. Building new infrastructure in remote areas
may help reduce the digital divide for these individuals.

86 AP Computer Science Principles Practice Exam


Question 41
Skill Learning Objective Topic
1.C: Explain how collaboration IOC-1.E: Explain how 5.4:
affects the development of a people participate in Crowdsourcing
solution. problem-solving processes
at scale.
(A) Correct. Crowdsourcing is the practice of using input or information
obtained from a large number of people via the Internet. In this case,
input on a player is provided by other players of the game.
(B) Incorrect. While this solution may reduce disrespectful communication
between players, it does not make use of input from a large number
of users.
(C) Incorrect. While this solution may reduce disrespectful communication
between players, it does not make use of input from a large number
of users.
(D) Incorrect. While this solution may reduce disrespectful communication
between players, it does not make use of input from a large number
of users.

Question 42
Skill Learning Objective Topic
4.B: Determine the result of AAP-2.O.b: For algorithms 3.10: Lists
code segments. involving elements of a list,
determine the result of an
algorithm that includes list
traversals.
(A) Correct. The expression (item MOD 2) evaluates to 1 for odd
values and evaluates to 0 for even values. As a result, the code
segment adds 1 to result for each odd value in integerList.
There are three odd values in the list, so 3 is displayed.
(B) Incorrect. This result would be displayed if the code segment counted
the number of even values in the list rather than the number of odd
values.
(C) Incorrect. This result would be displayed if the code segment computed
the sum of the odd values in the list rather than counting the number of
odd values in the list.
(D) Incorrect. This result would be displayed if the code segment computed
the sum of the even values in the list rather than counting the number of
odd values in the list.

AP Computer Science Principles Practice Exam 87


Question 43
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-2.C: Explain how 5.6: Safe
computing based on legal and unauthorized access to Computing
ethical factors. computing resources is
gained.
(A) Correct. Keylogging is the use of a program to record every keystroke
made by a computer to gain fraudulent access to passwords and other
confidential information.
(B) Incorrect. This is an example of a weak password. While a weak
password may enable an unauthorized user to gain access to a computer
system, it is not an example of keylogging.
(C) Incorrect. This is an example of intercepted network data. While
intercepted network data may enable an unauthorized user to gain
access to a computer system, it is not an example of keylogging.
(D) Incorrect. This is an example of phishing. While phishing may enable
an unauthorized user to gain access to a computer system, it is not an
example of keylogging.

Question 44
Skill Learning Objective Topic
1.D: Evaluate solution options. DAT-1.B: Explain the 2.1: Binary
consequences of using bits Numbers
to represent data.
(A) Incorrect. An overflow occurs when a value exceeds the maximum
representable value. This type of error does not typically lead to
imprecision of values.
(B) Correct. The fixed number of bits used to represent real numbers limits
the range of these values; this limitation can result in round-off errors.
Round-off errors typically result in imprecise values or results.
(C) Incorrect. Programming languages typically represent numbers with
a fixed number of bits. The use of a fixed number of bits can lead to
overflow or round-off errors.
(D) Incorrect. Programming languages typically represent numbers with
a fixed number of bits. The use of a fixed number of bits can lead to
overflow or round-off errors.

88 AP Computer Science Principles Practice Exam


Question 45
Skill Learning Objective Topic
3.B: Use abstraction to manage AAP-3.A.a: For procedure 3.12: Calling
complexity in a program. calls, write statements to call Procedures
procedures.
(A) Incorrect. In this code segment, the first call to botStepper moves
the robot forward two squares, rotates it left so that it faces toward the
top of the grid, moves it forward two squares, and rotates it right so
that it faces right. The second call to botStepper moves the robot
forward three squares, rotates it left so that it faces toward the top of the
grid, moves it forward three squares, and rotates it right so that it faces
right. The robot ends one square to the left of the gray square.
(B) Incorrect. In this code segment, the first call to botStepper moves
the robot forward three squares, rotates it left so that it faces toward
the top of the grid, moves it forward three squares, and rotates it right
so that it faces right. The second call to botStepper attempts to
moves the robot forward four squares, off the edge of the grid, causing
execution to terminate.
(C) Correct. In this code segment, the first call to botStepper moves
the robot forward two squares, rotates it left so that it faces toward the
top of the grid, moves it forward two squares, and rotates it right so
that it faces right. The code segment then moves the robot forward one
square. The second call to botStepper moves the robot forward
three squares, rotates it left so that it faces toward the top of the grid,
moves it forward three squares, and rotates it right so that it faces right.
The robot ends in the gray square.
(D) Incorrect. In this code segment, the first call to botStepper moves
the robot forward three squares, rotates it left so that it faces toward
the top of the grid, moves it forward three squares, and rotates it right
so that it faces right. The code segment then moves the robot forward
one square. The second call to botStepper attempts to moves the
robot forward four squares, off the edge of the grid, causing execution to
terminate.

AP Computer Science Principles Practice Exam 89


Question 46
Skill Learning Objective Topic
2.B: Implement and apply an DAT-2.D: Extract 2.4: Using
algorithm. information from data using Programs
a program. with Data
(A) Incorrect. Any ordering of the three steps will identify the correct
restaurant. Sequence III will work. Sorting by rating will put the greatest
customer rating at the top of the list. Then filtering by number of ratings
will remove restaurants without any ratings. Then filtering by payment
type will remove the restaurants that do not accept credit cards.
(B) Incorrect. Any ordering of the three steps will identify the correct
restaurant. Sequence II will work. Filtering by number of ratings will
remove restaurants without any ratings. Then sorting by rating will
put the greatest customer rating at the top of the list. Then filtering
by payment type will remove the restaurants that do not accept credit
cards.
(C) Incorrect. Any ordering of the three steps will identify the correct
restaurant. Sequence I will work. Filtering by number of ratings will
remove restaurants without any ratings. Then filtering by payment type
will remove the restaurants that do not accept credit cards. Then sorting
by rating will put the greatest customer rating at the top of the list.
(D) Correct. Because the relative order of the rows is not changed when the
filters are applied, the order in which the actions are performed does not
matter. The filtering can occur either before or after the spreadsheet is
sorted by rating.

Question 47
Skill Learning Objective Topic
2.B: Implement and apply an DAT-2.D: Extract 2.4: Using
algorithm. information from data using Programs
a program. with Data
(A) Incorrect. This expression will always evaluate to false because
prcRange cannot be equal to both "lo" and "med".
(B) Correct. This expression evaluates to true only for restaurants with
the correct price range (when prcRange equals "lo" or "med")
and the correct customer rating (when avgRating ≥ 4.0).
(C) Incorrect. This expression will evaluate to true for restaurants with
a correct customer rating and will evaluate to false for restaurants
with an incorrect customer rating, regardless of the price range. The
intent is to return true true for restaurants with the correct price
range and the correct customer rating.
(D) Incorrect. This expression will evaluate to true for restaurants with
the correct price range or with the correct customer rating. The intent
is for the expression to evaluate to true only for restaurants with the
correct price range and the correct customer rating.

90 AP Computer Science Principles Practice Exam


Question 48
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-2.C: Explain how 5.6: Safe
computing based on legal and unauthorized access to Computing
ethical factors. computing resources is
gained.
(A) Correct. A rogue access point is a wireless access point that gives
unauthorized access to secure networks. Data sent over public networks
can be intercepted, analyzed, and modified. One way that this can
happen is through a rogue access point.
(B) Incorrect. While disconnecting a router can be disruptive to users,
it does not allow unauthorized individuals to intercept information
transmitted on a network.
(C) Incorrect. Tricking a user into providing personal information is an
example of a phishing attack. While this type of attack can be used to
obtain personal information, it does not allow unauthorized individuals
to intercept information transmitted on a network.
(D) Incorrect. While overwhelming a router can be disruptive to users,
it does not allow unauthorized individuals to intercept information
transmitted on a network.

Question 49
Skill Learning Objective Topic
1.A: Investigate the situation, AAP-4.B: Explain the 3.18: Undecidable
context, or task. existence of undecidable Problems
problems in computer
science.
(A) Incorrect. While some solutions benefit from being validated by a
human, not all problems can be solved with an algorithm.
(B) Incorrect. While some solutions benefit from parallel computation, not
all problems can be solved with an algorithm.
(C) Incorrect. While some solutions require a large amount of data storage,
not all problems can be solved with an algorithm.
(D) Correct. An undecidable problem is one for which no algorithm can
be constructed that is always capable of providing a correct yes-or-
no answer. Some instances of an undecidable problem may have an
algorithmic solution, but there is no algorithmic solution that could
solve all instances of the problem.

AP Computer Science Principles Practice Exam 91


Question 50
Skill Learning Objective Topic
5.E: Evaluate the use of IOC-2.B: Explain how 5.6: Safe
computing based on legal and computing resources can Computing
ethical factors. be protected and can be
misused.
(A) Correct. Symmetric encryption uses a single key for both encryption
and decryption of data. Since the key can be used to unlock the data, it
should be kept secret.
(B) Incorrect. Since symmetric encryption uses the same key to encrypt and
decrypt data, it should be kept secret.
(C) Incorrect. Symmetric encryption uses a single key.
(D) Incorrect. Symmetric encryption uses a single key. Public key
encryption uses a public key for encryption and a private key for
decryption.

Question 51
Skill Learning Objective Topic
1.C: Explain how collaboration IOC-1.E: Explain how 5.4:
affects the development of a people participate in Crowdsourcing
solution. problem-solving processes
at scale.
(A) Correct. Citizen science is scientific research conducted in whole or
part by distributed individuals, many of whom may not be scientists,
who contribute relevant data to research using their own computing
devices. This project would benefit from using a citizen science model
for gathering photographs of birds from amateur photographers around
the world.
(B) Incorrect. This project can be done by a small team of researchers and is
not likely to require a distributed approach.
(C) Incorrect. A simulation is run on a computer and is not likely to require
input from individuals distributed around the world.
(D) Incorrect. This project requires specialized equipment that is unlikely to
be available to individuals distributed around the world.

92 AP Computer Science Principles Practice Exam


Question 52
Skill Learning Objective Topic
1.D: Evaluate solution options. AAP-2.P: For binary search 3.11: Binary
algorithms— a. Determine Search
the number of iterations
required to find a value in
a data set. b. Explain the
requirements necessary to
complete a binary search.
(A) Incorrect. After 2 binary search iterations on a list of length 128, there
will still be 32 elements remaining.
(B) Correct. The binary search algorithm starts at the middle of the list and
repeatedly eliminates half the elements until the desired value is found
or all elements have been eliminated. For a list with 128 elements, the
list will be cut in half a maximum of 7 times (causing 8 elements to be
examined). The list will start with 128 elements, then 64 elements, then
32 elements, then 16 elements, then 8 elements, then 4 elements, then 2
elements, then 1 element.
(C) Incorrect. While a binary search on a list of length 128 will eliminate
64 elements on the first iteration, fewer than 64 iterations are needed to
eliminate all elements.
(D) Incorrect. A linear search of a list of length 128 may examine all 128
elements. A binary search requires fewer elements to be examined.

Question 53
Skill Learning Objective Topic
2.A: Represent algorithmic AAP-2.J: Express an 3.8: Iteration
processes without using a algorithm that uses
programming language. iteration without using a
programming language.
(A) Correct. Step 4 checks every element of the list, incrementing count
each time target appears. Step 5 prints true if and only if
count appears multiple times in the list.
(B) Incorrect. This algorithm will only display true if every element in
the list is equal to target. In step 5, it is not possible for count
to be greater than position, and count will only be equal to
position if count was incremented for every element in the list.
(C) Incorrect. If target appears two or fewer times in the list, count
will never be greater than 2. Steps 2 and 3 will be continually repeated
until the algorithm eventually attempts to access a list element at an
index beyond the end of the list.
(D) Incorrect. It is not possible for count to be greater than n.
Steps 2 and 3 will be continually repeated until the algorithm eventually
attempts to access a list element at an index beyond the end of the list.

AP Computer Science Principles Practice Exam 93


Question 54
Skill Learning Objective Topic
5.B: Explain how knowledge DAT-2.A: Describe 2.3: Extracting
can be generated from data. what information can be Information
extracted from data. from Data
(A) Incorrect. This information can be determined by analyzing the dates
and times that trucks entered and left the depot.
(B) Correct. The data captured each time a truck enters or leaves the depot
do not include any information about the number of customers or
deliveries associated with the truck.
(C) Incorrect. This information can be determined by comparing the weight
of a truck when it last entered the depot to its weight when it last left
the depot.
(D) Incorrect. This information can be determined by analyzing the dates
and times that trucks entered and left the depot.

Question 55
Skill Learning Objective Topic
2.B: Implement and apply an AAP-2.N.a: For list 3.10: Lists
algorithm. operations, write
expressions that use
list indexing and list
procedures.
(A) Incorrect. This code segment assigns the value of the last element of
the list to the variable temp, then removes the last element of the list,
then appends temp to the end of the list. The resulting list is the same
as the original list.
(B) Incorrect. This code segment removes the last element of the list, then
attempts to access an element at index len. This causes an error
because there is no longer an element at index len.
(C) Correct. This code segment assigns the value of the last element of the
list to the variable temp, then removes the last element of the list,
then inserts temp as the first element of the list.
(D) Incorrect. This code segment removes the last element of the list, then
attempts to access an element at index len. This causes an error
because there is no longer an element at index len.

94 AP Computer Science Principles Practice Exam


Question 56
Skill Learning Objective Topic
5.B: Explain how knowledge DAT-2.A: Describe 2.3: Extracting
can be generated from data. what information can be Information
extracted from data. from Data
(A) Correct. The desired information can be determined by using the
student IDs in spreadsheet II to identify the students who play a sport.
Once the students who play a sport are identified, the grade point
averages of students who play sports in spreadsheet I can be compared
to the grade point averages of all other students in spreadsheet I.
(B) Incorrect. The desired information cannot be determined with these
two spreadsheets because students who play a single sport cannot be
identified.
(C) Incorrect. The desired information cannot be determined with these
two spreadsheets because students with grade point averages of 3.5 or
less cannot be identified.
(D) Incorrect. The desired information cannot be determined with these
two spreadsheets because students who play a single sport and students
with grade point averages of 3.5 or less cannot be identified.

Question 57
Skill Learning Objective Topic
1.D: Evaluate solution options. CSN-2.A.b: For sequential, 4.3: Parallel
parallel, and distributed and Distributed
computing, determine the Computing
efficiency of solutions.
(A) Correct. With two processors running in parallel, execution time is
minimized when the processors take on as close to an equal workload
as possible. Running processes P and Q on one processor will take a
total of 40 seconds. Running processes R and S on the other processor
will take a total of 35 seconds. As the processors run in parallel, all four
operations are completed in 40 seconds.
(B) Incorrect. Running processes P and R on one processor will take a
total of 50 seconds. Running processes Q and S on the other processor
will take a total of 25 seconds. With the processors running in parallel,
this solution will take 50 seconds; the optimal solution takes only 40
seconds.
(C) Incorrect. Running processes P and S on one processor will take a total
of 45 seconds. Running processes Q and R on the other processor will
take a total of 30 seconds. With the processors running in parallel,
this solution will take 45 seconds; the optimal solution takes only 40
seconds.
(D) Incorrect. Running process P on one processor will take a total of 30
seconds. Running processes Q, R, and S on the other processor will
take a total of 45 seconds. With the processors running in parallel,
this solution will take 45 seconds; the optimal solution takes only 40
seconds.

AP Computer Science Principles Practice Exam 95


Question 58
Skill Learning Objective Topic
3.A: Generalize data sources CRD-2.C: Identify input(s) 1.2: Program
through variables. to a program. Function
and Purpose
(A) Incorrect. Information about available running routes would not need
to be collected from the user’s device. In addition, the user may not be
currently located near the user’s home.
(B) Incorrect. The application does not necessarily need to know the current
time in order to recommend a running route.
(C) Incorrect. The application does not need to know the starting location
of the user’s previous run in order to recommend a running route.
(D) Correct. In order to suggest a running route, the application needs to
know the current location of the user. This information is collected from
the user’s device.

Question 59
Skill Learning Objective Topic
3.A: Generalize data sources CRD-2.C: Identify input(s) 1.2: Program
through variables. to a program. Function
and Purpose
(A) Incorrect. While Adrianna’s average running speed is useful in
determining whether other users are considered compatible with
Adrianna, this information is determined using data collected from
Adrianna’s device.
(B) Incorrect. While Adrianna’s preferred running distance is needed to
recommend a running route, this information is provided directly by
Adrianna.
(C) Correct. In order to share Adrianna’s running route with nearby users,
the application needs to know the current locations of users other than
Adrianna. This information is collected from other user’s devices, not
Adrianna’s device.
(D) Incorrect. While the usernames on Adrianna’s contact list is useful
in determining whether other users are considered compatible with
Adrianna, this information is determined using data provided directly
by Adrianna when she creates her contact list.

96 AP Computer Science Principles Practice Exam


Question 60
Skill Learning Objective Topic
5.C: Describe the impact of a IOC-1.A: Explain how 5.1: Beneficial
computing innovation. an effect of a computing and Harmful
innovation can be both Effects
beneficial and harmful.
(A) Incorrect. Using a mobile application outside of a user’s home is likely to
increase, not decrease, the user's mobile data usage.
(B) Incorrect. The application only sends notifications to compatible users
who are nearby. Since not all people will be considered compatible, users
are unlikely to be able to identify all other users in the area.
(C) Correct. The application can be used to connect users with other nearby
users, which may encourage users to exercise together. This may have
the effect of improving user health.
(D) Incorrect. The application relies on geolocation information in order to
suggest a running route. In addition, the application requires network
connectivity in order to send and receive data.

Question 61
Skill Learning Objective Topic
5.D: Describe the impact of IOC-2.A: Describe the risks 5.6: Safe
gathering data. to privacy from collecting Computing
and storing personal data
on a computer system.
(A) Incorrect. While some users may find it undesirable to carry their
smartphones while running, this is not considered a privacy concern.
(B) Correct. The application will inform a user whenever a nearby
compatible user starts a run. This could allow users to determine the
location of a stranger, which is considered a privacy concern.
(C) Incorrect. While running data captured by the application may be
inaccurate if two users are using the same account, this is not considered
a privacy concern.
(D) Incorrect. While a user may not be able to make full use of the
application’s features if there are no compatible users nearby, this is not
considered a privacy concern.

AP Computer Science Principles Practice Exam 97


Question 62
Skill Learning Objective Topic
5.C: Describe the impact of a IOC-1.B: Explain how a 5.1: Beneficial
computing innovation. computing innovation can and Harmful
have an impact beyond its Effects
intended purpose.
(A) Incorrect. Any two users with a basic account can receive targeted
advertisements, even if they appear on each other’s contact lists.
(B) Incorrect. Any user with a basic account can receive targeted
advertisements, regardless of whether they are interested in health
and fitness.
(C) Correct. Users with a premium account do not receive advertisements.
(D) Incorrect. Any user with a basic account can receive targeted
advertisements. If a user’s running route is located near a particular
business, that information can be used to target an advertisement to
the user.

Question 131
Skill Learning Objective Topic
2.B: Implement and apply an AAP-2.F.a: For relationships 3.5: Boolean
algorithm. between Boolean values, Expressions
write expressions using
logical operators.
(A) Correct. When input1 and input2 are both true,
the expressions (NOT input1) and (NOT input2) are
both false, so (NOT input1) OR (NOT input2) will
evaluate to false. In all other cases, either (NOT input1)
or (NOT input2) (or both) will evaluate to true,
so (NOT input1) OR (NOT input2) will evaluate to true.
(B) Incorrect. For example, when input1 is true and
input2 is false, then (NOT input1) will be false
and (NOT input2) will be true. Therefore,
(NOT input1) AND (NOT input2) will be false
instead of the intended value true.
(C) Incorrect. For example, when input1 is true and input2
is false, then (input1 OR input2) will be true.
Therefore, NOT (input1 OR input2) will be false
instead of the intended value true.
(D) Correct. When input1 and input2 are both true,
the expression (input1 AND input2) is true, so
NOT (input1 AND input2) will evaluate to false. In all
other cases, (input1 AND input2) will evaluate to false,
so NOT (input1 AND input2) will evaluate to true.

98 AP Computer Science Principles Practice Exam


Question 132
Skill Learning Objective Topic
4.C: Identify and correct errors CRD-2.I.b: For errors in 1.4: Identifying
in algorithms and programs, an algorithm or program, and Correcting
including error discovery correct the error. Errors
through testing.
(A) Incorrect. This line should not be removed. The variable result is
assigned the value "adult" by default and then assigned the value
"senior citizen" or "minor" only when appropriate.
(B) Correct. This line should be removed. This return statement causes
execution of the procedure to end early. As a result, if age is less than
18, result will never be assigned the value "minor".
(C) Correct. This line should be removed. This statement causes result
to be assigned the value "adult", even if it should have been
assigned the value "senior citizen".
(D) Incorrect. This line should not be removed. The value of result
should be returned at the end of the procedure, after age is compared
to both 65 and 18.

Question 133
Skill Learning Objective Topic
4.B: Determine the result of AAP-2.H.b: For selection, 3.6: Conditionals
code segments. determine the result of
conditional statements.
(A) Incorrect. Since hot is true, the body of the IF statement is
executed. Since hot AND humid evaluates to false, false
is displayed.
(B) Correct. Since NOT humid evaluates to true, the body of the IF
statement is executed. Since hot OR humid evaluates to true,
true is displayed.
(C) Correct. Since hot OR humid evaluates to true, the body of the
IF statement is executed. Since hot is true, true is displayed.
(D) Incorrect. Since hot AND humid evaluates to false, the body
of the IF statement is not executed, and nothing is displayed.

AP Computer Science Principles Practice Exam 99


Question 134
Skill Learning Objective Topic
2.B: Implement and apply an AAP-2.H.a: For selection, 3.6: Conditionals
algorithm. write conditional
statements.
(A) Correct. This code segment assigns 500 bonus points by default.
If timer is less than 30, no additional bonus points are added.
If timer is between 30 and 60 inclusive, bonus is
incremented by 500 in the first IF block. If timer is greater
than 60, bonus is incremented by 500 twice (once in each
IF block). The correct number of bonus points is assigned to bonus
for all possible values of timer.
(B) Incorrect. This code segment does not work as intended. For example,
if timer is greater than 60, bonus will be initially assigned
1500, then decreased to 1000 in the first IF block. As a result,
bonus will be assigned 1000 instead of the intended 1500.
(C) Incorrect. This code segment does not work as intended. For example,
if timer is greater than 60, bonus is assigned 1500 in the first
IF block. Then bonus is assigned 1000 in the second IF block.
As a result, bonus will be assigned 1000 instead of the intended
1500.
(D) Correct. In this code segment, if timer is greater than 60, bonus
is assigned 1500 in the first IF block. If timer is between 30
and 60, inclusive, bonus is assigned 1000 in the second IF block.
If timer is less than 30, bonus is assigned 500 in the third
IF block. The correct number of bonus points is assigned to bonus
for all possible values of timer.

100 AP Computer Science Principles Practice Exam


Question 135
Skill Learning Objective Topic
2.B: Implement and apply an AAP-3.E.a: For generating 3.15: Random
algorithm. random values, write Values
expressions to generate
possible values.
(A) 1
Correct. For this spinner, there is a chance of "blue". The
4
3
remaining of the time, "orange" and "purple" are equally
4
1
likely. If the first call to RANDOM returns 1 (which occurs of the
4
time), the code segment prints "blue". Otherwise, if the second
1
call to random returns 1 (which occurs of the time that "blue"
2
1
does not occur), the code segment prints "orange". The other
2
of the time that "blue" does not occur, the code segment prints

"purple".
(B) 3
Incorrect. This code segment simulates a spinner in which there is a
4
1 1
chance of "blue", a chance of "orange", and a chance of
8 8
1
"purple". However, the given spinner has a chance of "blue",
4
3 3
a chance of "orange", and a chance of "purple".
8 8
(C) 1
Incorrect. This code segment simulates a spinner in which there is a
4
1 1
chance of "blue", a chance of "orange", and a chance of
4 2
1
"purple". However, the given spinner has a chance of "blue",
4
3 3
a chance of "orange", and a chance of "purple".
8 8
(D) 1
Correct. For this spinner, there is a chance of "blue". The
4
3
remaining of the time, "orange" and "purple" are equally
4
likely. The variable spin is set to a random value between 1 and
1
4, inclusive. If spin is 1 (which occurs of the time), the code
4
segment prints "blue". Otherwise, spin is set to a random value
1
between 1 and 2, inclusive. If spin is 2 (which occurs
2
of the time that "blue" does not occur), the code segment prints
1
"orange". The other of the time that "blue" does not occur,
2
the code segment prints "purple".

AP Computer Science Principles Practice Exam 101


Question 136
Skill Learning Objective Topic
1.B: Determine and design CRD-2.J: Identify inputs 1.4: Identifying
an appropriate method or and corresponding expected and Correcting
approach to achieve the outputs or behaviors that Errors
purpose. can be used to check the
correctness of an algorithm
or program.
(A) Correct. The code segment will iterate over myList from right
to left, removing each element that is equal in value to the element
immediately preceding it. For this list, the code segment will remove the
sixth element (10), the fourth element (20), and the second element
(10). This results in the list [10, 20, 10], which still contains
duplicates.
(B) Incorrect. The code segment will iterate over myList from right to
left, removing the sixth element (20), the third element (30), and the
second element (30). This results in the list [30, 10, 20], which
contains no duplicates, as intended.
(C) Correct. The code segment will iterate over myList from right
to left, removing each element that is equal in value to the element
immediately preceding it. This list does not contain any pairs of adjacent
elements that are equal in value, so no elements will be removed even
though the value 40 appears twice in the list.
(D) Incorrect. The code segment will iterate over myList from right
to left, removing the all elements but the first. This results in the list
[50], which contains no duplicates, as intended.

Question 137
Skill Learning Objective Topic
5.B: Explain how knowledge DAT-2.B: Describe what 2.3: Extracting
can be generated from data. information can be Information
extracted from metadata. from Data
(A) Correct. The time and date that a photo is taken is considered metadata
about the image. This information can be used to determine the
chronological order of the images.
(B) Incorrect. The number of clouds in a particular picture cannot be
determined from the date, time, and location metadata. To determine
this information, the content of the picture itself must be analyzed.
(C) Incorrect. The suitability of a picture for printing in black-and-white
cannot be determined from the date, time, and location metadata. To
determine this information, the colors of the pixels in the photo must be
analyzed.
(D) Correct. The location and date that a photo is taken is considered
metadata about the image. This information can be used to determine
whether two pictures were taken at the same location on different dates.

102 AP Computer Science Principles Practice Exam


Question 138
Skill Learning Objective Topic
3.B: Use abstraction to manage AAP-3.A.a: For procedure 3.12: Calling
complexity in a program. calls, write statements to call Procedures
procedures.
(A) Correct. This code segment assigns the characters to the left of position
n to the variable left and the characters to the right of position
n to the variable right. It then concatenates left and right
and assigns the result to newStr. For example, if oldStr is
"best" and n is 3, the code segment assigns "be" to left,
"t" to right, and "bet" to newStr.
(B) Incorrect. This code segment assigns the characters from the start of
the string to one past position n to the variable left. The code
segment then assigns the characters from one before position n to
the end of the string to the variable right. It then concatenates
left and right and assigns the result to newStr. For example,
if oldStr is "best" and n is 3, the code segment assigns
"best" to left, "est" to right, and "bestest" to
newStr.
(C) Correct. This code segment assigns the characters to the left of position
n to newStr. The code segment then concatenates newStr with
the substring consisting of the characters to the right of position n.
For example, if oldStr is "best" and n is 3, the code
segment assigns "be" to newStr, then concatenates "be"
and the substring "t" and assigns the result "bet" to newStr.
(D) Incorrect. This code segment assigns the characters to the right of
position n to newStr. The code segment then concatenates
newStr with the substring consisting of the characters to the left
of position n. For example, if oldStr is "best" and n is 3,
the code segment assigns "t" to newStr, then concatenates "t"
and the substring "be" and assigns the result "tbe" to newStr.

AP Computer Science Principles Practice Exam 103


Answer Key and Question Alignment to Course
Framework
Multiple-Choice Answer Skill Learning Topic
Question Objective
1 D 5 .E IOC-2 .C 5 .6: Safe Computing
2 A 2 .B AAP-2 .F .a 3 .5: Boolean Expressions
3 A 4 .B AAP-1 .B 3 .1: Variables
and Assignments
4 D 5 .A CSN-1 .D 4 .1: The Internet
5 A 2 .B AAP-2 .K .a 3 .8: Iteration
6 C 5 .E IOC-2 .B 5 .6: Safe Computing
7 C 2 .A AAP-2 .J 3 .8: Iteration
8 C 1 .D CSN-1 .E .a 4 .2:Fault Tolerance
9 B 3 .C DAT-1 .A 2 .1: Binary Numbers
10 C 2 .B DAT-1 .C .a 2 .1: Binary Numbers
11 D 2 .B DAT-1 .C .a 2 .1: Binary Numbers
12 C 2 .B AAP-2 .H .a 3 .6: Conditionals
13 C 1 .C CRD-1 .A 1 .1: Collaboration
14 C 4 .C CRD-2 .I .b 1 .4: Identifying
and Correcting Errors
15 A 3 .B AAP-3 .A .a 3 .12: Calling Procedures
16 B 5 .E IOC-1 .F 5 .5: Legal and Ethical Concerns
17 B 1 .D CSN-1 .E .c 4 .2: Fault Tolerance
18 C 1 .D CSN-1 .E .c 4 .2: Fault Tolerance
19 D 5 .E IOC-2 .B 5 .6: Safe Computing
20 D 5 .A CSN-1 .A 4 .1: The Internet
21 A 1 .D DAT-1 .B 2 .1: Binary Numbers
22 A 1 .D AAP-2 .L 3 .9: Developing Algorithms
23 B 5 .A CSN-1 .B 4 .1: The Internet
24 C 1 .D DAT-1 .D 2 .2: Data Compression
25 D 4 .B AAP-2 .K .b 3 .8: Iteration
26 A 1 .D CSN-2 .B 4 .3: Parallel
and Distributed Computing
27 B 5 .E IOC-1 .D 5 .3: Computing Bias
28 D 2 .A AAP-2 .J 3 .8: Iteration
29 D 2 .A AAP-2 .J 3 .8: Iteration
30 B 5 .A CSN-1 .C 4 .1: The Internet
31 C 2 .B DAT-1 .C .b 2 .1: Binary Numbers
32 A 5 .E IOC-2 .B 5 .6: Safe Computing

104 AP Computer Science Principles Practice Exam


Multiple-Choice Answer Skill Learning Topic
Question Objective
33 B 1 .D AAP-4 .A .b 3 .17: Algorithmic Efficiency
34 B 4 .C CRD-2 .I .b 1 .4: Identifying
and Correcting Errors
35 B 5 .B DAT-2 .A 2 .3: Extracting Information
from Data
36 D 5 .D IOC-2 .A 5 .6: Safe Computing
37 C 4 .B AAP-2 .I .b 3 .7: Nested Conditionals
38 D 1 .D AAP-3 .F .b 3 .16: Simulations
39 C 2 .B DAT-1 .C .a 2 .1: Binary Numbers
40 B 5 .C IOC-1 .C 5 .2: Digital Divide
41 A 1 .C IOC-1 .E 5 .4: Crowdsourcing
42 A 4 .B AAP-2 .O .b 3 .10: Lists
43 A 5 .E IOC-2 .C 5 .6: Safe Computing
44 B 1 .D DAT-1 .B 2 .1: Binary Numbers
45 C 3 .B AAP-3 .A .a 3 .12: Calling Procedures
46 D 2 .B DAT-2 .D 2 .4: Using Programs with Data
47 B 2 .B DAT-2 .D 2 .4: Using Programs with Data
48 A 5 .E IOC-2 .C 5 .6: Safe Computing
49 D 1 .A AAP-4 .B 3 .18: Undecidable Problems
50 A 5 .E IOC-2 .B 5 .6: Safe Computing
51 A 1 .C IOC-1 .E 5 .4: Crowdsourcing
52 B 1 .D AAP-2 .P 3 .11: Binary Search
53 A 2 .A AAP-2 .J 3 .8: Iteration
54 B 5 .B DAT-2 .A 2 .3: Extracting Information
from Data
55 C 2 .B AAP-2 .N .a 3 .10: Lists
56 A 5 .B DAT-2 .A 2 .3: Extracting Information
from Data (2 .3)
57 A 1 .D CSN-2 .A .b 4 .3: Parallel and Distributed
Computing
58 D 3 .A CRD-2 .C 1 .2: Program Function
and Purpose
59 C 3 .A CRD-2 .C 1 .2: Program Function
and Purpose
60 D 5 .C IOC-1 .A 5 .1: Beneficial
and Harmful Effects
61 B 5 .D IOC-2 .A 5 .6: Safe Computing
62 C 5 .C IOC-1 .B 5 .1: Beneficial
and Harmful Effects

AP Computer Science Principles Practice Exam 105


Multiple-Choice Answer Skill Learning Topic
Question Objective
131 A,D 2 .B AAP-2 .F .a 3 .5: Boolean Expressions
132 B,C 4 .C CRD-2 .I .b 1 .4: Identifying
and Correcting Errors
133 B,C 4 .B AAP-2 .H .b 3 .6: Conditionals
134 A,D 2 .B AAP-2 .H .a 3 .6: Conditionals
135 A,D 2 .B AAP-3 .E .a 3 .15: Random Values
136 A,C 1 .B CRD-2 .J 1 .4: Identifying
and Correcting Errors
137 A,D 5 .B DAT-2 .B 2 .3: Extracting Information
from Data
138 A,C 3 .B AAP-3 .A .a 3 .12: Calling Procedures

106 AP Computer Science Principles Practice Exam


Contact Us
apcentral.collegeboard.org

New York Office


250 Vesey Street
New York, NY 10281
212-713-8000
212-713-8277/55 (Fax)

AP Services for Educators


P.O. Box 6671
Princeton, NJ 08541-6671
877-274-6474 (toll free in the United States and Canada)
212-632-1781
610-290-8979 (fax)
Email: [email protected]

AP Canada Office
2950 Douglas Street, Suite 550
Victoria, BC, Canada V8T 4N4
250-472-8561
800-667-4548 (toll free in Canada only)
Email: [email protected]

College Board International


Serving all countries outside the United States and Canada
250 Vesey Street
New York, NY 10281
212-373-8738
Email: [email protected]

AP Computer Science Principles Practice Exam 107


apcentral.collegeboard.org

You might also like