AP Computer Science Principles 2020 Practice Exam 1 MCQ 3
AP Computer Science Principles 2020 Practice Exam 1 MCQ 3
• For the remaining questions, numbered 131 through 137, 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.
You have 2 hours for this exam. Open your exam booklet and begin
Note Start Time here______ . Note Stop Time here______ . A"er 2 hours, say:
Stop working. The exam is over. I will now collect your exam materials.
Multiple Choice
At a Glance Instructions
This exam booklet contains 67 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.
67
Percent of Total Score Indicate all of your answers to the multiple-choice questions on the answer sheet. No
60% 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 For questions 1 through 6 , select the single best answer choice for each question.
None allowed
For questions 131 through 137, 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.
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
• Robot
Instruction Explanation
Assignment, Display, and Input
Text: Evaluates expression and assigns the result to
a ← expression the variable a.
Block:
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
{ evaluates to true; no action is taken if
<block of statements> condition evaluates to false.
}
Block:
Iteration
Text: The code in block of statements is
REPEAT n TIMES executed n times.
{
<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: Refers to the element of list at index i. The
list[i] first element of list is at index 1.
Block:
Procedures
Text: A procedure, name, takes zero or more
PROCEDURE name (parameter1, parameters. The procedure contains programming
parameter2, ...) instructions.
{
<instructions>
}
Block:
Block:
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:
Which of the following expressions represents the value stored in the variable x as a result of executing the
program?
(A) 2 * 3 * 3 * 3
(B) 2 * 4 * 4 * 4
(C) 2 * 3 * 3 * 3 * 3
(D) 2 * 4 * 4 * 4 * 4
2. A small team of wildlife researchers is working on a project that uses motion-activated field cameras to capture
images of animals at study sites. The team is considering using a “citizen science” approach to analyze the
images. Which of the following best explains why such an approach is considered useful for this project?
(A) Distributed individuals are likely to be more accurate in wildlife identification than the research team.
(B) The image analysis is likely to be more consistent if completed by an individual citizen.
(C) The image analysis is likely to require complex research methods.
(D) The image analysis is likely to take a longer time for the research team than for a distributed group of
individuals.
(A) (B)
(C) (D)
For which of the following input values will the circuit have an output of true ?
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 best describes the correctness of the programs?
(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.
Which of the following code segments correctly displays the cost of a ticket?
According to information in the table, what color is represented by the binary RGB
triplet (11111111, 11111111, 11110000) ?
(A) Ivory
(B) Light yellow
(C) Neutral gray
(D) Vivid yellow
Step 1: Input a positive integer from the user and store it in the variable number.
Step 2: Divide number by 10 and record the integer quotient and the remainder. The
integer quotient is the quotient with any part after the decimal point dropped. For
example, when 127 is divided by 10, the quotient is 12.7, the integer quotient
is 12 and the remainder is 7.
Which of the following can be used as step 3 so that the algorithm works as intended?
(A) Step 3: Display the remainder of number divided by 10 and store the remainder in number.
(B) Step 3: Display the remainder of number divided by 10 and store the integer quotient in number.
(C) Step 3: Display the integer quotient of number divided by 10 and store the remainder in number.
(D) Step 3: Display the integer quotient of number divided by 10 and store the integer quotient
in number.
Which of the following best compares the values displayed by programs A and B?
(A) Program A and program B display identical values in the same order.
(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 B displays one more value than program A.
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) REPEAT UNTIL (CAN_MOVE (forward) = false)
{
ROTATE_RIGHT ()
}
MOVE_FORWARD ()
(B) REPEAT UNTIL (CAN_MOVE (forward) = false)
{
MOVE_FORWARD ()
}
ROTATE_RIGHT ()
(C) REPEAT UNTIL (CAN_MOVE (right))
{
ROTATE_RIGHT ()
}
MOVE_FORWARD ()
Which of the following best describes the average amount of data stored per user for the first eight years of the
application’s existence?
(A) Across all eight years, the average amount of data stored per user was about 10 GB.
(B) Across all eight years, the average amount of data stored per user was about 100 GB.
(C) The average amount of data stored per user appears to increase by about 10 GB each year.
(D) The average amount of data stored per user appears to increase by about 100 GB each year.
Which of the following observations is most consistent with the information in the circle graph?
(A) Over 75% of the files stored are 1 MB in size or less.
(B) Over 75% of the files stored are 10 MB in size or less.
(C) Over 75% of the files stored are at least 100 KB in size.
(D) Over 75% of the files stored are at least 1 MB in size.
Which of the following code segments can be used to simulate the behavior of the spinner?
(A)
(B)
(D)
Block Explanation
Oval The start or end of the algorithm
Diamond A conditional or decision step, where execution
proceeds to the side labeled true if the
condition is true and to the side labeled false
otherwise
Rectangle One or more processing steps, such as a
statement that assigns a value to a variable
(A)
(B)
(C)
(D)
6 A list of binary values (0 or 1) is used to represent a black-and-white image. Which of the following is LEAST
likely to be stored as metadata associated with the image?
(A) Copyright information for the image
(B) The date and time the image was created
(C) The dimensions (number of rows and columns of pixels) of the image
(D) A duplicate copy of the data
(C) The ability of a computer to solve a problem is limited by the bandwidth of the computer’s Internet
connection.
(D) There exist some problems that cannot be solved using any algorithm.
. Assume that the variables alpha and beta each are initialized with a numeric value. Which of the
following code segments can be used to interchange the values of alpha and beta using the temporary
variable temp ?
I.
II.
III.
(A) When the application is shared only with students at the same school
(B) When the application is shared on a peer-to-peer network
(C) When the student gets permission from the copyright owner of the application
(D) When the student makes a copy of the application for another student to use only once
. A programmer is writing a program to calculate a student’s course grade using the process described. The
programmer has the following procedures available.
(A) For a given student, the value of the highest assignment score
(B) For a given student, the value of the lowest assignment score
(C) For a given student, the change in course grade as a result of dropping the lowest score
(D) The proportion of students who improved their course grade as a result of dropping the lowest score
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)
(A) Procedure Min (x, y), which returns the lesser of its two integer parameters
(B) Procedure Max (numList), which returns the maximum value in the list of integers numList
(C) Procedure MaxFour (w, x, y, z), which returns the greatest of its four integer parameters
(D) Procedure OverMax (numList, max), which returns the number of integers in numList that
exceed the integer value max
6 A group of planners are using a simulation to examine whether or not a park that they are designing is going to
affect foot traffic in the area. The simulation uses a model that includes input variables for the park such as the
number of entrances, sidewalks, and bike trails and the square footage of open space (grassy areas). The simulation
can then be run multiple times using different values for the input variables to represent different park designs.
However, the simulation takes a very long time to run. The planners update the model by removing some variables
they consider less important than others. Of the following, which is the most likely effect the updated model will
have on the simulation?
(A) The updated model is likely to decrease the runtime of the simulation because the time required for
simulations generally depends on the complexity of the model used.
(B) The updated model is likely to decrease the runtime of the simulation because simulations that use older
models tend to require more time to run than simulations that use newer models.
(C) The updated model is unlikely to decrease the runtime of the simulation because the simulation is
computationally complex, regardless of the model used.
(D) The updated model is unlikely to provide any benefit because removing details from a model will
compromise the accuracy of the simulation.
. Assume that the list of numbers nums has more than 10 elements. The program below is intended to compute
and display the sum of the first 10 elements of nums.
Line 1: i ← 1
Line 2: sum ← 0
Line 3: REPEAT UNTIL (i > 10)
Line 4: {
Line 5: i ← i + 1
Line 6: sum ← sum + nums[i]
Line 7: }
Line 8: DISPLAY (sum)
Which change, if any, is needed for the program to work as intended?
(A) Lines 1 and 2 should be interchanged.
(B) Line 3 should be changed to REPEAT UNTIL (i ≥ 10).
(C) Lines 5 and 6 should be interchanged.
(D) No change is needed; the program works correctly.
(A) I only
(B) II only
(C) I and III
(D) II and III
In which of the configurations is it possible to have redundant routing between devices Q and V?
(A) Configuration I only
(B) Configuration II only
(C) Both configuration I and configuration II
(D) Neither configuration I nor configuration II
In configuration I, what is the minimum number of connections that must be broken or removed before device T
can no longer communicate with device U?
(A) One
(B) Two
(C) Three
(D) Four
(A) (B)
(C) (D)
7 The procedure BinarySearch (numList, target) correctly implements a binary search algorithm
on the list of numbers numList. The procedure returns an index where target occurs in numList, or -1 if
target does not occur in numList. Which of the following conditions must be met in order for the procedure
to work as intended?
(A) The length of numList must be even.
(B) The list numList must not contain any duplicate values.
(C) The values in numList must be in sorted order.
(D) The value of target must not be equal to -1.
An office uses an application to assign work to its staff members. The application uses a binary sequence to
represent each of 100 staff members. What is the minimum number of bits needed to assign a unique bit
sequence to each staff member?
(A) 5
(B) 6
(C) 7
(D) 8
(A) I only
(B) II only
(C) III only
(D) I and II
. Assume that the list originalList contains integer values and that the list newList is initially empty.
The following code segment is intended to copy all even numbers from originalList to newList so that
the numbers in newList appear in the same relative order as in originalList. The code segment may
or may not work as intended.
Line 1: FOR EACH number IN originalList
Line 2: {
Line 3: IF (number MOD 2 = 0)
Line 4: {
Line 5: INSERT (newList, 1, number)
Line 6: }
Line 7: }
Which of the following changes, if any, can be made so that the code segment works as intended?
(A) Changing line 1 to FOR EACH number IN newList
(B) Changing line 3 to IF (number MOD 2 = 1)
(C) Changing line 5 to APPEND (newList, number)
(D) No change is needed; the code segment is correct as is.
Step 3: Each standing person finds another standing person and they form a pair. If a person
cannot find an unpaired standing person, that person remains standing and waits
until the next opportunity to form pairs.
Step 4: In each pair, one person hands their card to the other person and sits down.
Step 5: At this point, the standing person in each pair is holding two cards. The standing
person in each pair replaces the top number on their card with the sum of the top
numbers on the two cards and replaces the bottom number on their card with the
sum of the bottom numbers on the two cards. The sitting partner’s card is discarded.
Step 6: Repeat steps 3–5 until there is only one person standing.
Step 7: The last person standing divides the top number by the bottom number to determine
the average height.
Which of the following can be used as step 2 so that the algorithm works as intended?
(A) Step 2: Each person writes their height, in centimeters, at the top of the card and writes the number 1 at
the bottom of the card.
(B) Step 2: Each person writes their height, in centimeters, at the top of the card and writes the number 2 at
the bottom of the card.
(C) Step 2: Each person writes the number 1 at the top of the card and writes their height, in centimeters, at
the bottom of the card.
(D) Step 2: Each person writes the number 2 at the top of the card and writes their height, in centimeters, at
the bottom of the card.
Version I
topScore ← 0
idList ← [1298702, 1356846, 8848491, 8675309]
FOR EACH id IN idList
{
score ← GetPrediction (id)
IF (score > topScore)
{
topScore ← score
}
}
DISPLAY (topScore)
Version II
idList ← [1298702, 1356846, 8848491, 8675309]
topID ← idList[1]
FOR EACH id IN idList
{
IF (GetPrediction (id) > GetPrediction (topID))
{
topID ← id
}
}
DISPLAY (GetPrediction (topID))
Which of the following best compares the execution times of the two versions of the program?
(A) Version I requires approximately 1 more minute to execute than version II.
(B) Version I requires approximately 5 more minutes to execute than version II.
(C) Version II requires approximately 1 more minute to execute than version I.
(D) Version II requires approximately 5 more minutes to execute than version I.
. The following procedure is intended to return true if at least two of the three parameters are equal in value
and is intended to return false otherwise.
PROCEDURE AnyPairs (x, y, z)
{
IF (x = y)
{
RETURN (true)
}
ELSE
{
RETURN (y = z)
}
}
For which of the following procedure calls does the procedure NOT return the intended value?
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 in the corresponding
that begin with number 131 on the answer sheet.
131. Which of the following actions are likely to be helpful in reducing the digital divide?
(A) (B)
(C) (D)
For which of the following procedure calls does the procedure NOT return the intended value?
Select two answers.
(A)
(B)
(C)
(D)
Which of the following can be used to store the string "jackalope" in the string variable animal ?
Select two answers.
For which of the following code segments will the call to NumOccurrences NOT return the intended value?
Select two answers.
(A)
(B)
(C)
(D)
STOP