AP COMPUTER SCIENCE PRINCIPLES Scoring Guide
Day 7 Classwork
1. Consider the following code segment.
What is displayed as a result of executing the code segment?
(A) 1 3 5
(B) 5 3 1
(C) 100 300 500
(D) 500 300 100
2. 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?
AP Computer Science Principles Page 1 of 11
Scoring Guide
Day 7 Classwork
(A)
(B)
(C)
(D)
3. An algorithm is intended to display the following output.
red red blue red red blue red red blue
Which of the following code segments can be used to display the intended output?
Page 2 of 11 AP Computer Science Principles
Scoring Guide
Day 7 Classwork
(A)
(B)
(C)
(D)
4. The following code segment is used to determine whether a customer is eligible for a discount on a movie ticket.
val1 (NOT (category = "new")) OR (age ≥ 65)
val2 (category = "new") AND (age < 12)
If category is "new" and age is 20, what are the values of val1 and val2 as a result of executing
the code segment?
AP Computer Science Principles Page 3 of 11
Scoring Guide
Day 7 Classwork
(A) val1 = true, val2 = true
(B) val1 = true, val2 = false
(C) val1 = false, val2 = true
(D) val1 = false, val2 = false
5. Historically, it has been observed that computer processing speeds tend to double every two years. Which of the
following best describes how technology companies can use this observation for planning purposes?
Technology companies can accurately predict the dates when new computing innovations will be
(A)
available to use.
Technology companies can plan to double the costs of new products each time advances in processing
(B)
speed occur.
(C) Technology companies can set research and development goals based on anticipated processing speeds.
Technology companies can spend less effort developing new processors because processing speed will
(D)
always improve at the observed rate.
6. Consider the following procedure.
Procedure Call Explanation
drawCircle(xPos, Draws a circle on a coordinate grid with center (xPos, yPos)
yPos, rad) and radius rad
The drawCircle procedure is to be used to draw the following figure on a coordinate grid.
Let the value of the variable x be 2, the value of the variable y be 2, and the value of the variable r be
1. Which of the following code segments can be used to draw the figure?
Page 4 of 11 AP Computer Science Principles
Scoring Guide
Day 7 Classwork
drawCircle(x, y, r)
drawCircle(x, y + 2, r)
(A) drawCircle(x + 2, y, r)
drawCircle(x + 2, y + 2, r)
drawCircle(x, y, r)
drawCircle(x, y + 3, r)
(B) drawCircle(x + 3, y, r)
drawCircle(x + 3, y + 3, r)
drawCircle(x, y, r + 2)
drawCircle(x, y + 2, r + 2)
(C) drawCircle(x + 2, y, r + 2)
drawCircle(x + 2, y + 2, r + 2)
drawCircle(x, y, r + 3)
drawCircle(x, y + 3, r + 3)
(D) drawCircle(x + 3, y, r + 3)
drawCircle(x + 3, y + 3, r + 3)
7. Consider the following procedure.
Procedure Call Explanation
drawLine(x1, y1, Draws a line segment on a coordinate grid with endpoints at coordinates
x2, y2) (x1, y1) and (x2, y2)
The drawLine procedure is to be used to draw the following figure on a coordinate grid.
Let the value of the variable xVal be 6 and the value of the variable yVal be 5. Which of the following
code segments can be used to draw the figure?
AP Computer Science Principles Page 5 of 11
Scoring Guide
Day 7 Classwork
drawLine(1, 5, xVal, yVal)
(A) drawline(1, 5, xVal, yVal + 2)
drawline(1, 5, xVal, yVal + 2)
drawLine(1, 5, xVal, yVal)
(B) drawline(1, 5, xVal, yVal + 2)
drawline(1, 5, xVal, yVal - 2)
drawLine(1, 5, xVal, yVal)
(C) drawline(1, 5, xVal + 2, yVal + 2)
drawline(1, 5, xVal + 2, yVal - 2)
drawLine(1, 5, xVal, yVal)
(D) drawline(1, 5, xVal + 2, yVal + 2)
drawline(1, 5, xVal - 2, yVal - 2)
8. The procedure Draw (length, direction) is used to draw a line segment length units long in a given direction (left,
right, up, or down), starting at the current cursor position. The cursor is then repositioned at the end of the line
segment that was drawn. Consider the following program, where the cursor starts in the upper left corner of a grid
of dots. The dots are spaced one unit apart.
Draw (1, right)
Draw (2, down)
Draw (1, left)
Draw (1, right)
Draw (1, up)
Draw (1, left)
Which of the following represents the figure that is drawn by the program?
Page 6 of 11 AP Computer Science Principles
Scoring Guide
Day 7 Classwork
(A)
(B)
(C)
(D)
AP Computer Science Principles Page 7 of 11
Scoring Guide
Day 7 Classwork
9. Consider the following procedure.
Procedure Call Explanation
DrawLine (x1, y1, Draws a line segment on a coordinate grid with endpoints at coordinates
x2, y2) (x1, y1) and (x2, y2)
The DrawLine procedure is to be used to draw the following figure on a coordinate grid.
The following code segment is intended to draw the figure.
startX 2
startY 6
endX 8
endY 8
REPEAT 4 TIMES
{
<MISSING CODE>
}
Which of the following can be used to replace <MISSING CODE> so that the figure is drawn correctly?
Page 8 of 11 AP Computer Science Principles
Scoring Guide
Day 7 Classwork
DrawLine (startX, startY, endX, endY)
(A) endY endY - 2
DrawLine (startX, startY, endX, endY)
(B) endX endX - 2
endY endY - 2
endY endY - 2
(C) DrawLine (startX, startY, endX, endY)
endX endX - 2
(D) endY endY - 2
DrawLine (startX, startY, endX, endY)
10. 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.
11. A graphic artist uses a program to draw geometric shapes in a given pattern. The program uses an algorithm that
draws the shapes based on input from the artist. The table shows the approximate number of steps the algorithm
takes to draw different numbers of shapes.
Number of Number of
Shapes Drawn Steps
4 17
5 24
6 35
7 50
Based on the values in the table, which of the following best characterizes the algorithm for drawing shapes,
where is a very large number?
AP Computer Science Principles Page 9 of 11
Scoring Guide
Day 7 Classwork
The algorithm runs in a reasonable amount of time because it will use approximately steps to draw
(A)
shapes.
The algorithm runs in a reasonable amount of time because it will use approximately steps to draw
(B)
shapes.
The algorithm runs in an unreasonable amount of time because it will use approximately steps to draw
(C)
shapes.
The algorithm runs in an unreasonable amount of time because it will use approximately steps to
(D)
draw shapes.
12. 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 delivery locations. The company is considering two different algorithms for determining
delivery routes.
Algorithm I all possible routes, compute their lengths, and then select the shortest possible route. This
Generate
algorithm does not run in reasonable time.
Algorithm II from an arbitrary delivery location, find the nearest unvisited delivery location. Continue
Starting
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 .
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.
Algorithm II provides no improvement over algorithm I because neither algorithm runs in reasonable
(C)
time.
(D) Algorithm II requires a much faster computer in order to provide any improvement over algorithm I.
13. 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))
14. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
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?
Page 10 of 11 AP Computer Science Principles
Scoring Guide
Day 7 Classwork
(A) The sender’s public key
(B) The sender’s private key
(C) The recipient’s public key
(D) The recipient’s private key
15. 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
AP Computer Science Principles Page 11 of 11