WorksheetsAP Comp Sci AP Exam Review
Total questions: 48
Worksheet time: 38mins
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?
A
B
Based on the flowchart, what is the final value of the bonus if the timer is 45?
500
1000
1500
2000
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.
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.
Which of the following replacements for
IF (CAN_MOVE (forward)) { MOVE_FORWARD () ROTATE_RIGHT () }
IF (CAN_MOVE (right)) { ROTATE_RIGHT () MOVE_FORWARD () }
IF (CAN_MOVE (forward)) { MOVE_FORWARD () } ROTATE_RIGHT ()
IF (CAN_MOVE (right)) { (ROTATE_RIGHT) } MOVE_FORWARD ()
Consider the following code segment. What are the values of first and second as a result of executing the code segment?
first = 100, second = 100
first = 200, second = 100
first = 100, second = 200
first = 200, second = 200
Consider the following code segment. What are the values of first and second as a result of executing the code segment?
The value of first is true, and the value of second is true.
The value of first is true, and the value of second is false.
The value of first is false, and the value of second is true.
The value of first is false, and the value of second is false.
Consider the following code segment. x ← 25 y ← 50 z ← 75 x ← y y ← z z ← x Which of the variables have the value 50 after executing the code segment?
x only
y only
x, y, and z
x and z only
Consider the following code segment. What is the value of r as a result of executing the code segment?
20
30
40
10
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. 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?
3
4
2
1
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.
IF(CAN_MOVE(left))
{
ROTATE_LEFT()
MOVE_FORWARD()
}
IF(CAN_MOVE(left))
{
ROTATE_LEFT()
}
MOVE_FORWARD()
A byte =
8 Bits
4 Bits
9 Bits
6 Bits
Error from attempting to represent a number that is too large.
Binary
Overflow Error
Round-off Error
Error from attempting to represent a number that is too precise. The value is rounded.
Binary
Overflow Error
Round-off Error
A way of representing information using only two options.
Binary
Round-off Error
Overflow Error
Consider the following code segment. x ← 10 y ← 20 z ← 30 x ← z z ← y y ← x Which of the variables have the value 30 after executing the code segment?
z only
x only
x and y only
y only
After running the program what is the value of Start?
(a)
After running the program what is the value of Current?
(a)
The following program is run. Then the user clicks the "bottomButton" ONCE and then clicks the "topButton" ONCE. What will be displayed in the console?
chicken pig cow
cow pig chicken
cow chicken pig
pig cow chicken
data that are sent to a computer for processing by a program. Can come in a variety of forms, such as tactile interaction, audio, visuals, or text.
input
user interface
event driven processing
debugging
development process
the inputs and outputs that allow a user to interact with a piece of software. User interfaces can include a variety of forms such as buttons, menus, images, text, and graphics.
input
user interface
event driven processing
debugging
development process
the steps or phases used to create a piece of software. Typical phases include investigating, designing, prototyping, and testing
input
user interface
event driven processing
debugging
development process
some program statements run when triggered by an event, like a mouse click or a key press
input
user interface
event driven processing
debugging
development process
program statements run in order, from top to bottom
input
user interface
event driven processing
Sequential Programming
development process
a command or instruction. Sometimes also referred to as a code statement
input
user interface
event driven processing
Sequential Programming
program Statement
Which of the following expressions are equivalent to the value of expression as shown in the table?
Select two answers.
(NOT input1) OR (NOT input2)
(NOT input1) AND (NOT input2)
NOT (input1 OR input2)
NOT (input1 AND input2)
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.
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?
(avgRating ≥ 4.0) AND ((prcRange = "lo") AND (prcRange = "med"))
(avgRating ≥ 4.0) AND ((prcRange = "lo") OR (prcRange = "med"))
(avgRating ≥ 4.0) OR ((prcRange = "lo") AND (prcRange = "med"))
(avgRating ≥ 4.0) OR ((prcRange = "lo") OR (prcRange = "med"))
Which of the following Boolean expressions are equivalent to the expression num>= 15 ?
Select two answers.
(num > 15) and (num = 15)
(num > 15) or (num = 15)
NOT (num < 15)
NOT (num < 16 )
The cost of a customer’s electricity bill is based on the number of units of electricity the customer uses.
For the first 25 units of electricity, the cost is $5 per unit.
For units of electricity after the first 25, the cost is $7 per unit.
Which of the following code segments correctly sets the value of the variable cost to the cost, in dollars, of using numUnits units of electricity?
A color in a computing application is represented by an RGB triplet that describes the amount of red, green, and blue, respectively, used to create the desired color. A selection of colors and their corresponding RGB triplets are shown in the following table. Each value is represented in decimal (base 10).
According to information in the table, what color is represented by the binary RGB triplet (11111111, 11111111, 11110000) ?
Ivory
vivid yellow
indigo
pale yellow
magenta
A color in a computing application is represented by an RGB triplet that describes the amount of red, green, and blue, respectively, used to create the desired color. A selection of colors and their corresponding RGB triplets are shown in the following table. Each value is represented in decimal (base 10).
What is the binary RGB triplet for the color indigo?
(00100101, 00000000, 10000010)
(00100101, 00000000, 01000001)
(01001011, 00000000, 10000010)
(01001011, 00000000, 01000001)
What is the value of x after this code runs?
int x = 5;
x = 10;
x = 4;
5
10
4
true
A programmer is creating an algorithm that will be used to turn on the motor to open the gate in a parking garage. The specifications for the algorithm are as follows.
The gate should not open when the time is outside of business hours.
The motor should not turn on unless the gate sensor is activated.
The motor should not turn on if the gate is already open.
Which of the following algorithms can be used to open the gate under the appropriate conditions?
Check if the time is outside of business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is closed. If it is, turn on the motor.
Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is, turn on the motor.
Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is not, check if the gate is open. If it is not, turn on the motor.
Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.
Which of the following statements is equivalent to the algorithm in the flowchart?
include <- (floor > 10) or (bedrooms = 3)
include <- (floor > 10) and (bedrooms = 3)
include <- (floor <= 10) or (bedrooms = 3)
include <- (floor <= 10) and (bedrooms = 3)
Consider the following code segment, which uses the variables r, s, and t.
r ← 1
s ← 2
t ← 3
r ← s
s ← t
DISPLAY (r)
DISPLAY (s)
What is displayed as a result of running the code segment?
(a)
Which of the following Boolean expressions are equivalent to the expression num >= 15 ?
( num > 15 ) and ( num = 15)
( num > 15 ) or ( num = 15)
not ( num < 15 )
not ( num < 16 )
If the inputs A and C are both true, which of the following best describes the output of the AND gate?
The output will be true no matter what the value of input B is
The output will be false no matter what the value of input B is.
The output will be true if input B is true; otherwise it will be false.
The output will be false if input B is true; otherwise it will be true.
Which of the following school policies is most likely to have a positive impact on the digital divide?
A school allows students to bring a graphing calculator from home to complete in-class mathematics assignments.
A school allows students to bring a tablet computer to class every day to participate in graded quizzes.
A school provides a laptop or tablet computer to all students enrolled at the school.
A school recommends that all students purchase a computer with as much processing speed as possible so that projects run faster.
An online store uses 6-bit binary sequences to identify each unique item for sale. The store plans to increase the number of items it sells and is considering using 7-bit binary sequences. Which of the following best describes the result of using 7-bit sequences instead of 6-bit sequences?
2 more items can be uniquely identified.
10 more items can be uniquely identified.
2 times as many items can be uniquely identified.
10 times as many items can be uniquely identified.
For which of the following lists can a binary search be used to search for an item in the list?
I only
III only
I and III only
I, II, and III
A student is recording a song on her computer. When the recording is finished, she saves a copy on her computer. The student notices that the saved copy is of lower sound quality than the original recording. Which of the following could be a possible explanation for the difference in sound quality?
The song was saved using fewer bits per second than the original song.
The song was saved using more bits per second than the original song.
The song was saved using a lossless compression technique.
Some information is lost every time a file is saved from one location on a computer to another location.
True
False
True
False
What gets logged to the console?
[1, 2, 3, 4, 5]
1
myList
2
What gets logged to the console?
[1, 2, 3, 4, 5]
1
myList
error
What is displayed to the console log?
$10
$ 10
$10.00
error
What base is binary in?
2
4
1
7
How would you represent the number 5 in binary?
10
100
101
110
What number does 110 represent in binary?
6
3
8
12
What two numbers do we use in binary?
-1 & 0
2 & 1
1 & 0
4 & 0
