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 ?

Answer : C

Explanation : The code segment initially sets one word, ticket Price to 12, and then changes the price to 9 only for children and seniors. The code segment then increases One word, ticket Price by 5 for 3-D movies.


What is displayed as a result of executing the program?

Answer: 1 3

Explanation : The code segment initially sets start to 1, end to 20, and current to 3. Next, the code segment sets start to the value of current, which is 3. Then current is increased from 3 to 4. The final values of start and current are 3 and 4, respectively.


The procedure One word, Draw Circle, open parenthesis, x comma y comma r, close parenthesis can be used to draw a circle on a coordinate grid. The circle is centered at the coordinate x comma y and has a radius of runits. The procedure will be used to draw the following figure on a coordinate grid.

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

Answer : Option B code segment

Explanation: The code segment draws a circle centered at the coordinates (3, 6), then moves to the right and down, drawing circles centered at (5, 4) and (7, 2).


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.

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?

Answer: D

Explanation: The code segment selects “Yellow” one-sixth of the time, “Blue” one-sixth of the time, and “Red” the remaining two-thirds of the time.


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

Answer: C

Explanation: The programs each display ten values, but each value displayed by program B is one greater than the corresponding value from program A. Program A displays 1 2 3 4 5 6 7 8 9 10 and program B displays 2 3 4 5 6 7 8 9 10 11.


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?

Answer:The user will be in violation of the Digital Millennium Copyright Act (DMCA).

Explanation: If the album was purchased and downloaded through a licensed music store, the user will not be in violation of the DMCA.


Which of the following code segments will move the robot to the gray square?

Answer: B

Explanation: This code segment moves the robot forward two squares, rotates it right three times so that the robot faces the top of the grid, and then moves the robot forward three squares to the gray square.


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?

Answer : B

Explanation: Redundant routing is impossible if there is only one possible path from one device to another. There is only one possible path from P to S (P to R to Q to S).


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 which of the following strings is it NOT possible to use byte pair encoding to shorten the string’s length?

Answer : BANANA

Explanation : It is not possible to use byte pair encoding in the string Open quotation, LEVEL, underscore, UP, close quotationbecause no pair of characters appears in the string more than once.


The code segment below uses the procedure One word, Goal Reached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise.

Which of the following replacements for missing code can be used to move the robot to the gray square?

Answer: A

Expanation : The code segment rotates right whenever there is an open square to the right. The robot will move forward from its initial location to the upper-left corner of the grid, then rotate right, then move forward to the upper-right corner of the grid, then rotate right, then move down two squares, then rotate right, then move forward to the gray square.


While debugging the code, the student realizes that the loop never terminates. The student plans to insert the instruction Win, left arrow, true somewhere in the code. Where could Win, left arrow, true be inserted so that the code segment works as intended?

Answer : Between line 9 and 10

Explanation: Inserting Win, left arrow, true between line 9 and line 10 will cause the loop to terminate when the guess is correct.


In a certain science experiment, 7 5 percent of trials are expected to be successful and 2 5 percent of trials are expected to be unsuccessful. The program below is intended to simulate the results of repeated trials of the experiment.

Which of the following can be used to replace missing code so that the simulation works as intended?

Answer : RANDOM (1,100) <= 75

Explanation : This option causes the experiment to be successful when RANDOM, open parenthesis 1 comma 100, close parenthesis produces a result from 1 to 7 5, or 75% of the time.


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.

Which of the following best describes the result of running the procedure?

Answer: The procedrure always returns false

Explanation : The responses could always be false due to if y and yes are both entered it could be false