Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

AP CSP Practice Exam Full #1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 47

REFERENCE MATERIALS

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

Text: Displays the value of expression, followed by


DISPLAY (expression) a space.

Downloaded from open.773.im. Commercial use not authorized


Block:

Text: Accepts a value from the user and returns it.


INPUT ()
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, 3 / 2 evaluates to 1.5.
a / b
Text and Block: Evaluates to the remainder when a is divided
a MOD b by b. Assume that a and b are positive
integers.
For example, 17 MOD 5 evaluates to 2.
Text: Evaluates to a random integer from a to b,
RANDOM (a, b) including a and b.
Block: For example, RANDOM (1, 3) could evaluate
to 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 > b
a < b For example, a = b evaluates to true if a
a  b and b are equal; otherwise it evaluates to
a  b false.
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:

关注公众号omni_xyz获得更多AP备考资源
14 AP Computer Science Principles Practice Exam
REFERENCE MATERIALS

Instruction Explanation
Relational and Boolean Operators (continued)
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

Downloaded from open.773.im. Commercial use not authorized


{ 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:

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

关注公众号omni_xyz获得更多AP备考资源
AP Computer Science Principles Practice Exam 15
REFERENCE MATERIALS
Instruction Explanation
Iteration (continued)
Text: The code in block of statements is
REPEAT UNTIL (condition) repeated until the Boolean expression
{ condition evaluates to true.
<block of statements>
}
Block:

Downloaded from open.773.im. Commercial use not authorized


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: Refers to the element of list at index i. The
list[i] first element of list is at index 1.
Block:

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


list[i] ← list[j]
Block:

Text: Assigns value1, value2, and value3 to


list ← [value1, value2, value3] list[1], list[2], and list[3],
respectively.
Block:

Text: The variable item is assigned the value of each


FOR EACH item IN list element of list 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:

关注公众号omni_xyz获得更多AP备考资源
16 AP Computer Science Principles Practice Exam
REFERENCE MATERIALS
Instruction Explanation
List Operations (continued)
Text: Any values in list at indices greater than or
INSERT (list, i, value) equal to i are shifted to the right. The length of
list is increased by 1, and value is placed at
Block:
index i in list.

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


APPEND (list, value) value is placed at the end of list.

Downloaded from open.773.im. Commercial use not authorized


Block:

Text: Removes the item at index i in list and shifts


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

Text: Evaluates to the number of elements in list.


LENGTH (list)
Block:

Procedures
Text: A procedure, name, takes zero or more
PROCEDURE name (parameter1, parameters. The procedure contains programming
parameter2, ...) instructions.
{
<instructions>
}
Block:

Text: A procedure, name, takes zero or more


PROCEDURE name (parameter1, parameters. The procedure contains programming
parameter2, ...) instructions and returns the value of
{ expression. The RETURN statement may
<instructions> appear at any point inside the procedure and causes
RETURN (expression) an immediate return from the procedure back to the
} calling program.

Block:

关注公众号omni_xyz获得更多AP备考资源
AP Computer Science Principles Practice Exam 17
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
MOVE_FORWARD () direction it is facing.
Block:

Downloaded from open.773.im. Commercial use not authorized


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


ROTATE_RIGHT () (i.e., 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.

关注公众号omni_xyz获得更多AP备考资源
18 AP Computer Science Principles Practice Exam
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 fill in the corresponding circle on the answer sheet.

1. The code segment below is intended to swap the values of the variables first and second using a
temporary variable, temp.

Downloaded from open.773.im. Commercial use not authorized


Which of the following can be used to replace <MISSING CODE> so that the code segment works as
intended?
(A)

(B)

(C)

(D)

2. A bank customer receives an e-mail from a sender claiming to be a bank employee. The e-mail asks the
customer to provide personal information and to call a phone number if he or she has any questions. The
customer suspects the e-mail might be a phishing attempt. Which of the following responses is most likely to be
a privacy risk for the bank customer?

(A) Calling the bank at its official phone number to ask whether the request for personal information is
legitimate
(B) Calling the phone number given in the e-mail and providing the personal information over the phone
(C) Checking that the domain name of the sender’s e-mail address is associated with the bank
(D) Conducting a Web search to see if other people have received similar requests for personal information

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 19


3. Which of the following would be the best use of citizen science?

(A) An experiment that requires all participants to be working in the same laboratory
(B) An experiment that requires expensive equipment to conduct
(C) An experiment that requires data measurements to be taken in many different locations
(D) An experiment that requires specialized knowledge and training to conduct

Downloaded from open.773.im. Commercial use not authorized


4. A student is writing a program to model different real-world events using simulations. Which of the following
simulations will generate a result that would best be stored using a Boolean variable?

(A) A simulation of flipping a fair coin


(B) A simulation of rolling a fair die (with sides numbered 1 through 6)
(C) A simulation of the temperature in a location over time
(D) A simulation of traffic patterns on a road

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

20 AP Computer Science Principles Practice Exam


5. The ticket prices at a movie theater are given below.

Type of Ticket Price


(in dollars)
Regular 12
Child (ages 12 and below) 9
Senior (ages 60 and above) 9
Additional $5 fee for 3-D movies

Downloaded from open.773.im. Commercial use not authorized


A programmer is creating an algorithm to set the value of ticketPrice based on the information in the
table. The programmer uses the integer variable age for the age of the moviegoer. The Boolean variable
is3D is true when the movie is 3-D and false otherwise.
Which of the following code segments correctly sets the value of ticketPrice ?
(A) (B)

(C) (D)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 21


6. Which of the following best describes the role of the Internet Engineering Task Force (IETF) ?

(A) Developing standards and protocols for Internet communication


(B) Preventing copyrighted materials from being illegally distributed online
(C) Preventing malicious software from being distributed online
(D) Verifying the ownership of encrypted keys used in secured messages

Downloaded from open.773.im. Commercial use not authorized


7. Consider the following program, which uses the variables start, end, and current.
start ← 1
end ← 20
current ← 3
start ← current
current ← current + 1
DISPLAY (start)
DISPLAY (current)
What is displayed as a result of executing the program?
(A) 1 3
(B) 3 3
(C) 3 4
(D) 4 4

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

22 AP Computer Science Principles Practice Exam


8. Which of the following best characterizes a high-level programming language?

(A) A language comprised entirely of hardware logic gates


(B) A language in which each instruction corresponds directly to an instruction in a computer’s machine code
(C) A language that is easy for a computer to interpret but difficult for humans to interpret
(D) A language that uses multiple abstractions to manage complexity

Downloaded from open.773.im. Commercial use not authorized


9. A smartphone stores the following data for each photo that is taken using the phone.
• The file name of the photo
• The date and time the photo was taken
• The geographic location where the photo was taken
Assume that all of the photos that have been taken on the phone are accessible. Which of the
following can be determined using the photo data described above?
I. The number of photos that were taken at a particular geographic location
II. The number of photos that were taken in the last year
III. The name of the person who took the most recent photo

(A) III only


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

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 23


10. Which of the following best describes one of the benefits of using an iterative and incremental process of
program development?
(A) It allows programmers to implement algorithmic solutions to otherwise unsolvable problems.
(B) It eliminates the need for programmers to test completed programs.
(C) It enables programmers to create programs that use the lowest-level abstractions available.
(D) It helps programmers identify errors as components are added to a working program.

Downloaded from open.773.im. Commercial use not authorized

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

24 AP Computer Science Principles Practice Exam


11. The procedure DrawCircle (x, y, r) can be used to draw a circle on a coordinate grid. The circle is
centered at the coordinate (x, y) and has a radius of r units. The procedure will be used to draw the
following figure on a coordinate grid.

Downloaded from open.773.im. Commercial use not authorized


Which of the following code segments can be used to draw the figure?
(A) xPos ← 3 (B) xPos ← 3
yPos ← 6 yPos ← 6
REPEAT 3 TIMES REPEAT 3 TIMES
{ {
DrawCircle (xPos, yPos, 2) DrawCircle (xPos, yPos, 2)
xPos ← xPos + 2 xPos ← xPos + 2
yPos ← yPos + 2 yPos ← yPos - 2
} }

(C) xPos ← 7 (D) xPos ← 7


yPos ← 2 yPos ← 2
REPEAT 3 TIMES REPEAT 3 TIMES
{ {
DrawCircle (xPos, yPos, 2) DrawCircle (xPos, yPos, 2)
xPos ← xPos + 2 xPos ← xPos + 2
yPos ← yPos + 2 yPos ← yPos - 2
} }

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 25


12. A spinner is divided into three sections. The sector labeled Red is four times as large as each of the sectors
labeled Blue and Yellow, which are of equal size.

Downloaded from open.773.im. Commercial use not authorized


The procedure below is intended to simulate the behavior of the spinner.

Which of the following can be used to replace <MISSING CODE> so that the procedure correctly simulates
the spinner?
(A) (B)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

26 AP Computer Science Principles Practice Exam


(C) (D)

Downloaded from open.773.im. Commercial use not authorized

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 27


Questions 13–14 refer to the information below.
A social media site allows users to send messages to each other. A group of researchers gathered user data for the first
10 years of the site’s existence. Some of the data are summarized in the table below, along with some of the company
milestones.
Average Average
Total Number Average
Number of Number of
of Registered Number of
Year Milestone Active Daily Daily
Users (in Characters
Users (in Messages Sent
millions) Per Message
millions) Per User

Downloaded from open.773.im. Commercial use not authorized


1 Web site launched 25.4 0.8 3.6 360
2 26.0 0.7 3.5 362
3 26.5 0.6 3.5 358
4 26.9 0.6 3.4 360
5 Mobile app released 27.4 0.9 3.3 269
6 28.0 0.9 3.4 242
7 28.6 1.1 3.5 195
8 29.1 1.2 3.5 176
9 29.6 1.1 3.6 104
10 30.2 1.1 3.6 96

13. The researchers noticed that the total number of registered users appears to be increasing at about a constant
rate. If this pattern continues, which of the following best approximates the total number of registered users, in
millions, in year 12 (two years after the last entry in the table) ?

(A) 30.6
(B) 31.2
(C) 31.8
(D) 32.4

14. Which of the following hypotheses is most consistent with the data in the table?

(A) The mobile app release did not have any effect on the average number of daily messages sent per user.
(B) The mobile app release discouraged new user registration on the site.
(C) The mobile app release led to users being less frequently active on the site.
(D) The mobile app release led to users tending to write shorter messages.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

28 AP Computer Science Principles Practice Exam


15. Consider the two programs below.

Downloaded from open.773.im. Commercial use not authorized


Which of the following best compares the values displayed by programs A and B?

(A) Program A and program B display identical values.


(B) Program A and program B display the same values in different orders.
(C) Program A and program B display the same number of values, but the values differ.
(D) Program A and program B display a different number of values.

16. Which of the following is a true statement about Internet communication?


(A) Devices from different manufacturers are required to run the same operating system to communicate over
the Internet.
(B) Every device connected to the Internet is assigned a digital certificate by a certificate authority.
(C) Every device connected to the Internet is assigned an Internet protocol (IP) address.
(D) Every device connected to the Internet requires a high-bandwidth connection to enable redundant routing
to each device.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 29


17. A user reads reviews of a popular artist’s new album and then downloads the album from the Web site of a
licensed online music seller. Which of the following is LEAST likely to be a consequence of this action?
(A) Advertisements for the artist’s other albums will be displayed when the user visits a different Web site.
(B) Album reviews from other people who live nearby will be displayed to the user.
(C) Similar artists will be recommended to the user based on the user’s download selection.
(D) The user will be in violation of the Digital Millennium Copyright Act (DMCA).

Downloaded from open.773.im. Commercial use not authorized


18. Which of the following actions could be used to help reduce the digital divide?
I. Providing free education and training on how to use computing devices
II. Providing free or low-cost computing devices to low-income individuals
III. Providing networks and infrastructure to people in remote areas
(A) III only
(B) I and II only
(C) II and III only
(D) I, II, and III

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

30 AP Computer Science Principles Practice Exam


19. A population researcher is interested in predicting the number of births that will occur in a particular
community. She created a computer model that uses data from the past ten years, including number of residents
and the number of babies born. The model predicted that there would be 200 births last year, but the actual
number of births last year was only 120. Which of the following strategies is LEAST likely to provide a more
accurate prediction?

(A) Gathering data for additional years to try to identify patterns in birth rates
(B) Refining the model used in the computer simulation to more closely reflect the data from the past ten years

Downloaded from open.773.im. Commercial use not authorized


(C) Removing as many details from the model as possible so that calculations can be performed quickly
(D) Taking into consideration more information about the community, such as the ages of residents

20. A library of e-books contains metadata for each book. The metadata are intended to help a search feature find
books that users are interested in. Which of the following is LEAST likely to be contained in the metadata of
each e-book?
(A) An archive containing previous versions of the e-book
(B) The author and title of the e-book
(C) The date the e-book was first published
(D) The genre of the e-book (e.g., comedy, fantasy, romance, etc.)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 31


21. An application program interface (API) provides a procedure Max, which returns the greater of its two integer
arguments.
A programmer would like to find the greatest of three integer values a, b, and c. Which of the following
expressions will produce the desired result in every case?

(A) Max (Max (a, b), c)


(B) Max (a, b) - Max (b, c)

Downloaded from open.773.im. Commercial use not authorized


(C) Max (a, b) + Max (b, c) – Max (a, c)
(D) (Max (a, b) + Max (b, c)) / 2

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

32 AP Computer Science Principles Practice Exam


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

Downloaded from open.773.im. Commercial use not authorized


Consider the procedures below.

Which of the following code segments will move the robot to the gray square?
(A) (B)

(C) (D)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 33


23. A student is creating a procedure to determine whether the weather for a particular month was considered very
hot. The procedure takes as input a list containing daily high temperatures for a particular month. The procedure
is intended to return true if the daily high temperature was at least 90 degrees for a majority of days in the
month and return false otherwise.
PROCEDURE IsHot (temperatureList)
{
total ← 0
counter ← 0

Downloaded from open.773.im. Commercial use not authorized


FOR EACH temperature IN temperatureList
{
IF (temperature ≥ 90)
{
counter ← counter + 1
}
total ← total + 1
}
RETURN (<MISSING CODE>)
}
Which of the following can be used to replace <MISSING CODE> so that the procedure works as intended?
(A) counter < 0.5 * total
(B) counter > 0.5 * total
(C) total < 0.5 * counter
(D) total > 0.5 * counter

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

34 AP Computer Science Principles Practice Exam


24. The following figures represent different ways of configuring a network of physically linked computers labeled
P, Q, R, and S. A line between two computers indicates that the computers can communicate directly with each
other. In which configuration is it NOT possible to have redundant routing between computers P and S?
(A) (B)

Downloaded from open.773.im. Commercial use not authorized


(C) (D)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 35


Questions 25–26 refer to the information below.
Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in
the string more than once and replaces each instance of that pair with a corresponding character that does not appear in
the string. The algorithm saves a list containing the mapping of character pairs to their corresponding replacement
characters.
For example, the string "THIS_IS_THE_BEST_WISH" can be encoded as "%#_#_%E_BEST_W#H" by
replacing all instances of "TH" with "%" and replacing all instances of "IS" with "#".

Downloaded from open.773.im. Commercial use not authorized


25. Which of the following statements about byte pair encoding is true?
(A) Byte pair encoding is an example of a lossy transformation because it discards some of the data in the
original string.
(B) Byte pair encoding is an example of a lossy transformation because some pairs of characters are replaced
by a single character.
(C) Byte pair encoding is an example of a lossless transformation because an encoded string can be restored to
its original version.
(D) Byte pair encoding is an example of a lossless transformation because it can be used to transmit messages
securely.

26. For which of the following strings is it NOT possible to use byte pair encoding to shorten the string’s length?
(A) "BANANA"
(B) "LEVEL_UP"
(C) "MEET_ME_LATER"
(D) "NEITHER_HERE_NOR_THERE"

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

36 AP Computer Science Principles Practice Exam


27. The grid below contains a robot represented as a triangle, initially facing up. The robot can move into a white or
gray square but cannot move into a black region.

Downloaded from open.773.im. Commercial use not authorized


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 (right)) (B) IF (CAN_MOVE (right))
{ {
ROTATE_RIGHT () ROTATE_RIGHT ()
} MOVE_FORWARD ()
MOVE_FORWARD () }

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


{ {
MOVE_FORWARD () MOVE_FORWARD ()
} ROTATE_RIGHT ()
ROTATE_RIGHT () }

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 37


28. Which of the following allows users to refer to Web sites using names, such as example.com, rather than
numbers, such as 93.184.216.34 ?
(A) A digital certificate
(B) The domain name system (DNS)
(C) The hypertext transfer protocol (HTTP)
(D) The simple mail transfer protocol (SMTP)

Downloaded from open.773.im. Commercial use not authorized


29. Which of the following is an underlying assumption that is made when Moore’s law is used?

(A) As computer hardware improves, the algorithms used in programs will become more efficient.
(B) As computer hardware improves, developers will become more skilled at writing code.
(C) As computer hardware improves, future computers will be able to run faster than current computers.
(D) As computer hardware improves, the number of cybersecurity concerns will increase.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

38 AP Computer Science Principles Practice Exam


30. A student wrote the following code for a guessing game.
Line 1: secretNumber ← RANDOM (1, 100)
Line 2: win ← false
Line 3: REPEAT UNTIL (win)
Line 4: {
Line 5: DISPLAY ("Guess a number.")
Line 6: guess ← INPUT ()

Downloaded from open.773.im. Commercial use not authorized


Line 7: IF (guess = secretNumber)
Line 8: {
Line 9: DISPLAY ("You got it right!")
Line 10: }
Line 11: ELSE
Line 12: {
Line 13: IF (guess > secretNumber)
Line 14: {
Line 15: DISPLAY ("Your guess is too high.")
Line 16: }
Line 17: ELSE
Line 18: {
Line 19: DISPLAY ("Your guess is too low.")
Line 20: }
Line 21: }
Line 22: }
While debugging the code, the student realizes that the loop never terminates. The student plans to insert the
instruction win ← true somewhere in the code. Where could win ← true be inserted so that the
code segment works as intended?
(A) Between line 6 and line 7
(B) Between line 9 and line 10
(C) Between line 20 and 21
(D) Between line 21 and 22

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 39


31. A text-editing application uses binary sequences to represent each of 200 different characters. What is the
minimum number of bits needed to assign a unique bit sequence to each of the possible characters?
(A) 4
(B) 6
(C) 7
(D) 8

Downloaded from open.773.im. Commercial use not authorized


32. The diagram below shows a circuit composed of three logic gates. Each gate takes two inputs and produces a
single output.

For which of the following input values will the circuit have an output of false?
(A) A = true, B = false, C = false, D = false
(B) A = true, B = true, C = false, D = false
(C) A = false, B = false, C = true, D = true
(D) A = false, B = false, C = false, D = true

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

40 AP Computer Science Principles Practice Exam


33. A video-streaming service maintains a database of information about its customers and the videos they have
watched.
The program below analyzes the data in the database and compares the number of viewers of science fiction
videos to the number of viewers of videos of other genres. It uses the procedure Analysis (category),
which returns the number of unique users who viewed videos of a given category in the past year. The
Analysis procedure takes approximately 1 hour to return a result, regardless of the number of videos of the
given genre. All other operations happen nearly instantaneously.

Downloaded from open.773.im. Commercial use not authorized


sciFiFans ← Analysis ("science fiction")
genreList ← ["comedy", "drama", "mystery", "romance"]
FOR EACH genre IN genreList
{
IF (Analysis (genre) > sciFiFans)
{
DISPLAY (genre)
}
}
Which of the following best approximates the amount of time it takes the program to execute?

(A) 1 hour
(B) 2 hours
(C) 4 hours
(D) 5 hours

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 41


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

Downloaded from open.773.im. Commercial use not authorized


The following programs are each intended to move the robot to the gray square. Program II uses the
procedure GoalReached, which returns true if the robot is in the gray square and returns false
otherwise.

Which of the following statements is true?


(A) Program I correctly moves the robot to the gray square, but program II does not.
(B) Program II correctly moves the robot to the gray square, but program I does not.
(C) Both program I and program II correctly move the robot to the gray square.
(D) Neither program I nor program II correctly moves the robot to the gray square.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

42 AP Computer Science Principles Practice Exam


35. A color is often represented by a 6-digit hexadecimal number that describes how the colors red, green, and blue
are mixed to create the desired color. From left to right, the first two digits represent the amount of red, the
second two digits represent the amount of green, and the last two digits represent the amount of blue. Which of
the following hexadecimal numbers represents the color with the greatest amount of blue in it?

(A) 0099A1
(B) A10099
(C) A100B0

Downloaded from open.773.im. Commercial use not authorized


(D) FFA100

36. Participants in a survey were asked how many hours per day they spend reading, how many hours per day they
spend using a smartphone, and whether or not they would be interested in a smartphone application that lets
users share book reviews.

The data from the survey are represented in the graph below. Each × represents a survey participant who said he
or she was interested in the application, and each O represents a participant who said he or she was not
interested.

Which of the following hypotheses is most consistent with the data in the graph?
(A) Participants who read more were generally more likely to say they are interested in the application.
(B) Participants who read more were generally less likely to say they are interested in the application.
(C) Participants who use a smartphone more were generally more likely to say they read more.
(D) Participants who use a smartphone more were generally less likely to say they read more.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 43


37. A flowchart is a way to visually represent an algorithm. The flowchart below is used by an apartment rental Web
site to set the variable include to true for apartments that meet certain criteria.

Block Explanation
The start or end of the algorithm

A conditional or decision step, where execution proceeds to the side


labeled true if the condition is true and to the side labeled

Downloaded from open.773.im. Commercial use not authorized


false otherwise
One or more processing steps, such as a statement that assigns a
value to a variable

Which of the following statements is equivalent to the algorithm in the flowchart?


(A) include ← (floor > 10) OR (bedrooms = 3)
(B) include ← (floor > 10) AND (bedrooms = 3)
(C) include ← (floor ≤ 10) OR (bedrooms = 3)
(D) include ← (floor ≤ 10) AND (bedrooms = 3)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

44 AP Computer Science Principles Practice Exam


38. A researcher wrote a program to simulate the number of mice in an environment that contains predators. The
program uses the following procedures.

Procedure Call Explanation


InitialMousePopulation () Returns the number of mice at the start of the
simulation
InitialPredatorPopulation () Returns the number of predators at the start of
the simulation
NextDayPopulation (numberOfMice, Based on the current numbers of mice and

Downloaded from open.773.im. Commercial use not authorized


numberOfPredators) predators, returns the number of mice after one
day
Code for the simulation is shown below.
days ← 0
numMice ← InitialMousePopulation ()
numPredators ← InitialPredatorPopulation ()
REPEAT UNTIL (days = 365)
{
numMice ← NextDayPopulation (numMice, numPredators)
days ← days + 1
}
DISPLAY ("There are")
DISPLAY (numMice)
DISPLAY ("mice after one year.")
Based on the code, which of the following assumptions is made in the simulation?

(A) The number of mice increases by 1 each day.


(B) The number of mice does not change from day to day.
(C) The number of predators increases by 1 each day.
(D) The number of predators does not change from day to day.

39. The latency of a network connection is most appropriately measured with which of the following units?
(A) Bits per byte
(B) Bits per second
(C) Bytes
(D) Milliseconds

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 45


40. A musician is creating a song using audio samples. Which of the following actions will minimize the risk of a
copyright violation when creating sample-based music?
(A) Using samples found on popular music-streaming sites
(B) Using samples found on peer-to-peer networks
(C) Using samples from nondigital sound sources (vinyl records, tapes, etc.)
(D) Using samples published with a no-rights-reserved Creative Commons license

Downloaded from open.773.im. Commercial use not authorized


41. A computer program performs the operation 2 ÷ 3 and represents the result as the value 0.6666667.
Which of the following best explains this result?
(A) An overflow error occurred.
(B) The precision of the result is limited due to the constraints of using a floating-point representation.
(C) The program attempted to execute the operation with the arguments in reverse order.
(D) The program attempted to represent a floating-point number as an integer.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

46 AP Computer Science Principles Practice Exam


42. The two code segments below are each intended to display the average of the numbers in the list numList.
Assume that numList contains more than one value.

Downloaded from open.773.im. Commercial use not authorized


Which of the following best describes the two code segments?
(A) Code segment I displays the correct average, but code segment II does not.
(B) Code segment II displays the correct average, but code segment I does not.
(C) Both code segments display the correct average, but code segment I requires more arithmetic operations
than code segment II.
(D) Both code segments display the correct average, but code segment II requires more arithmetic operations
than code segment I.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 47


43. A snack bar has a frequent customer program in which every 10th purchase is free. Customers are enrolled in
the program when they make their first purchase. A programmer is writing a program to implement the frequent
customer program. In one code segment, cost is set to 0 for every 10th purchase by a given customer. The
programmer will use the procedure GetCount (customerID), which returns the total number of
purchases a customer has made since enrolling in the frequent customer program, including his or her first
purchase.
Which of the following code segments will set cost to 0 for every 10th purchase a customer makes after
enrolling in the frequent customer program?

Downloaded from open.773.im. Commercial use not authorized


(A) count ← GetCount (customerID)
IF (count / 10 = 0)
{
cost ← 0
}

(B) count ← GetCount (customerID)


IF (NOT (count / 10 = 0))
{
cost ← 0
}

(C) count ← GetCount (customerID)


IF (count MOD 10 = 0)
{
cost ← 0
}

(D) count ← GetCount (customerID)


IF (NOT (count MOD 10 = 0))
{
cost ← 0
}

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

48 AP Computer Science Principles Practice Exam


44. Which of the following explains a benefit of using open standards and protocols for Internet communication?

(A) Open standards and protocols allow different manufacturers and developers to build hardware and software
that can communicate with hardware and software on the rest of the network.
(B) Open standards and protocols provide ways for users to eliminate the latency of messages they send on the
Internet.
(C) Open standards and protocols allow users to freely share or reuse material found on the Internet for
noncommercial purposes.

Downloaded from open.773.im. Commercial use not authorized


(D) Open standards and protocols prevent developers from releasing software that contains errors.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 49


Questions 45–46 refer to the information below.
Grades in a computer science course are based on total points earned on a midterm exam and a final exam. The teacher
provides a way for students to improve their course grades if they receive high scores on the final exam: if a student’s
final exam score is greater than the student’s midterm exam score, the final exam score replaces the midterm exam
score in the calculation of total points.
The table below shows two students’ scores on the midterm and final exams and the calculated total points each student
earns.
Student Name Midterm Exam Score Final Exam Score Total Points Calculation
Khalil 90 80 90 ˜ 80 ° 170

Downloaded from open.773.im. Commercial use not authorized


Josefina 70 90 90 ˜ 90 ° 180

• Khalil does better on the midterm exam than on the final exam, so his original midterm and
final exam scores are added to compute his total points.
• Josefina does better on the final exam than on the midterm exam, so her final exam score
replaces her midterm exam score in the total points calculation.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

50 AP Computer Science Principles Practice Exam


45. The teacher has data representing the scores of thousands of students. For each student, the data contain the
student name, the midterm exam score, the final exam score, and the result of the total points calculation. Which
of the following could be determined from the data?
I. The average total points earned per student
II. The average increase in total points per student as a result of the score replacement policy
III. The proportion of students who improved their total points as a result of the score replacement policy

Downloaded from open.773.im. Commercial use not authorized


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

46. A programmer is writing a procedure to calculate a student’s final grade in the course using the score
replacement policy described. The student’s exam scores are stored in the variables midtermExam and
finalExam. The procedure Max (a, b) returns the larger of a and b.
Which of the following could be used in the procedure to calculate a student’s total points earned in the course
and store the result in the variable adjustedTotal?
(A) adjustedTotal ← Max (midtermExam, finalExam)

(B) adjustedTotal ← Max (midtermExam, finalExam) + finalExam

(C) adjustedTotal ← Max (midtermExam, finalExam) + midtermExam

(D) adjustedTotal ← 2 * Max (midtermExam, finalExam)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 51


47. Internet protocol version 4 (IPv4) represents each IP address as a 32-bit binary number. Internet protocol
version 6 (IPv6) represents each IP address as a 128-bit binary number. Which of the following best describes
the result of using 128-bit addresses instead of 32-bit addresses?
(A) 4 times as many addresses are available.
(B) 96 times as many addresses are available.

(C) 24 times as many addresses are available.

Downloaded from open.773.im. Commercial use not authorized


(D) 296 times as many addresses are available.

48. An online retailer uses an algorithm to sort a list of n items by price. The table below shows the approximate
number of steps the algorithm takes to sort lists of different sizes.

Number of Items Number of Steps


10 100
20 400
30 900
40 1,600
50 2,500
60 3,600
Based on the values in the table, which of the following best characterizes the algorithm for very large values
of n ?
(A) The algorithm runs in reasonable time.
(B) The algorithm runs, but not in reasonable time.
(C) The algorithm attempts to solve an undecidable problem.
(D) The algorithm attempts to find an approximate solution whenever it fails to find an exact solution.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

52 AP Computer Science Principles Practice Exam


49. A computer program uses 4 bits to represent nonnegative integers. Which of the following statements describe a
possible result when the program uses this number representation?
I. The operation 4 + 8 will result in an overflow error.
II. The operation 7 + 10 will result in an overflow error.
III. The operation 12 + 3 will result in an overflow error.

(A) I only

Downloaded from open.773.im. Commercial use not authorized


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

50. A NAND gate is a type of logic gate that produces an output of false only when both of its two inputs
are true. Otherwise, the gate produces an output of true. Which of the following Boolean expressions
correctly models a NAND gate with inputs P and Q ?
(A) (NOT P) AND (NOT Q)
(B) (NOT P) AND Q
(C) NOT (P AND Q)
(D) NOT (P OR Q)

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 53


51. A student wants to create an algorithm that can determine, given any program and program input, whether or not
the program will go into an infinite loop for that input.
The problem the student is attempting to solve is considered an undecidable problem. Which of the following is
true?

(A) It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm can only be implemented in a low-level programming language.
(B) It is possible to create an algorithm that will solve the problem for all programs and inputs, but the

Downloaded from open.773.im. Commercial use not authorized


algorithm requires simultaneous execution on multiple CPUs.
(C) It is possible to create an algorithm that will solve the problem for all programs and inputs, but the
algorithm will not run in reasonable time.
(D) It is not possible to create an algorithm that will solve the problem for all programs and inputs.

52. In public key cryptography, the sender uses the recipient’s public key to encrypt a message. Which of the
following is needed to decrypt the message?

(A) The sender’s public key


(B) The sender’s private key
(C) The recipient’s public key
(D) The recipient’s private key

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

54 AP Computer Science Principles Practice Exam


53. In a certain science experiment, 75 percent of trials are expected to be successful and 25 percent of trials are
expected to be unsuccessful. The program below is intended to simulate the results of repeated trials of the
experiment.
successful ← 0
unsuccessful ← 0
REPEAT 1000 TIMES
{

Downloaded from open.773.im. Commercial use not authorized


IF (<MISSING CODE>)
{
successful ← successful + 1
}
ELSE
{
unsuccessful ← unsuccessful + 1
}
}
DISPLAY (successful)
DISPLAY ("trials were successful,")
DISPLAY (unsuccessful)
DISPLAY ("trials were unsuccessful.")
Which of the following can be used to replace <MISSING CODE> so that the simulation works as intended?
(A) RANDOM (1, 100) = 25
(B) RANDOM (1, 100) ≤ 25
(C) RANDOM (1, 100) = 75
(D) RANDOM (1, 100) ≤ 75

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 55


54. The code segment below is intended to display all multiples of 5 between the values start and end,
inclusive. For example, if start has the value 35 and end has the value 50, the code segment should
display the values 35, 40, 45, and 50. Assume that start and end are multiples of 5 and
that start is less than end.
Line 1: i ← start
Line 2: REPEAT <MISSING EXPRESSION> TIMES
Line 3: {
Line 4: DISPLAY (i)

Downloaded from open.773.im. Commercial use not authorized


Line 5: i ← i + 5
Line 6: }

Which of the following could replace <MISSING EXPRESSION> in line 2 so that the code segment works as
intended?
(A) end - start + 1
(B) end - start + 6
(C) ((end - start) / 5) + 1
(D) 5 * (end - start) + 1

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

56 AP Computer Science Principles Practice Exam


55. The procedure below searches for the value target in list. It returns true if target is found and
returns false otherwise.

Downloaded from open.773.im. Commercial use not authorized


Which of the following are true statements about the procedure?
I. It implements a binary search.
II. It implements a linear search.
III. It only works as intended when list is sorted.
(A) I only
(B) II only
(C) I and III
(D) II and III

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 57


56. Which of the following is an example of symmetric encryption?

(A) Evy buys a locked box that operates using two different codes. When the first code is entered, a slot opens
that allows a message to be put in the box. When the second code is entered, the door to the box opens.
Evy gives the first code to her friends so they can leave messages for her and keeps the second code to
herself so that she is the only one who can retrieve the messages.
(B) Finn and Gwen develop a system that maps each letter of the alphabet to a unique symbol using a secret
key. Finn uses the key to write a message to Gwen where each letter is replaced with the corresponding

Downloaded from open.773.im. Commercial use not authorized


symbol. Gwen uses the key to map each symbol back to the original letter.
(C) Hannah writes a message to send to Isabel and hides the message under a rock behind the soccer field.
Hannah gives Isabel the exact location of the rock so that only Isabel can find the message.
(D) Juan writes a message to send to Kelly and slides the message through a slot in the front of Kelly’s locker.
Juan knows that Kelly has not shared her locker combination with anyone, so no one other than Kelly will
be able to read the message.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

58 AP Computer Science Principles Practice Exam


57. A programmer is developing a word game. The programmer wants to create an algorithm that will take a list of
words and return a list containing the first letter of all words that are palindromes (words that read the same
backward or forward). The returned list should be in alphabetical order. For example, if the list contains the
words ["banana", "kayak", "mom", "apple", "level"], the returned list would contain
["k", "l", "m"] (because "kayak", "level", and "mom" are palindromes).

The programmer knows that the following steps are necessary for the algorithm but is not sure in which order
they should be executed.

Downloaded from open.773.im. Commercial use not authorized


Step Explanation
Shorten Takes a list of words and returns a new list that contains only the
first letter of each word from the input list
Keep Takes a list of words and returns a list that contains only the
palindromes palindromes from the input list
Sort Takes a list of words and returns a copy of the list in alphabetical
order
Executing which of the following sequences of steps will enable the algorithm to work as intended?
I. First shorten, then keep palindromes, then sort
II. First keep palindromes, then shorten, then sort
III. First sort, then keep palindromes, then shorten
(A) I only
(B) II only
(C) I and III
(D) II and III

58. Which of the following best describes the purpose of machine learning programs?

(A) To analyze large data sets, recognize patterns, and make predictions based on data
(B) To automatically translate algorithms from natural language to machine language
(C) To determine whether an algorithm can be constructed to answer “yes” or “no” for all possible inputs
(D) To find approximate solutions to problems that would otherwise require an unreasonably long amount of
time to solve

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

AP Computer Science Principles Practice Exam 59


59. A programmer notices the following two procedures in a library. The procedures do similar, but not identical,
things.

• Procedure Square (n) returns the value n 2 .


• Procedure Cube (n) returns the value n3.
Which of the following procedures is a generalization of the procedures described above?

(A) Procedure Add (n, m), which returns the value n + m

Downloaded from open.773.im. Commercial use not authorized


(B) Procedure Fourth (n), which returns the value n4

(C) Procedure Polynomial(n), which returns the value n3 + n 2

(D) Procedure Power (n, m), which returns the value n m

60. A student wrote the procedure below, which is intended to ask whether a user wants to keep playing a game.
The procedure does not work as intended.
PROCEDURE KeepPlaying ()
{
DISPLAY ("Do you want to continue playing (y/n)?")
response ← INPUT ()
IF ((response = "y") AND (response = "yes"))
{
RETURN (true)
}
ELSE
{
RETURN (false)
}
}
Which of the following best describes the result of running the procedure?

(A) The procedure returns true when the user inputs the value "y" and returns false otherwise.
(B) The procedure returns true when the user inputs the value "n" and returns false otherwise.
(C) The procedure returns true no matter what the input value is.
(D) The procedure returns false no matter what the input value is.

关注公众号omni_xyz获得更多AP备考资源
GO ON TO THE NEXT PAGE.

60 AP Computer Science Principles Practice Exam

You might also like