T1-Mock Answers 2
T1-Mock Answers 2
Term 1 - Mock 1
1. Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms,
which are each intended to identify the people in the room who have the earliest birthday based on just the month
and day. For example, a person born on February 10 is considered to have an earlier birthday than a person born on
March 5. Which of the three algorithms will identify the correct people?
I. All the people in the room stand up. All standing people form pairs where possible, leaving at most one
person not part of a pair. For each pair, the person with the earlier birthday remains standing, while the
other person in the pair sits down. If there is a tie, both people sit down. Any individual not part of a
pair remains standing. Continue doing this until only one person remains standing. That person has the
earliest birthday.
II. All the people in the room stand up. All standing people form pairs with another standing person that
they have not previously been paired with where possible, leaving at most one person not part of a pair.
For each pair, the person with the earlier birthday remains standing, while the other person in the pair
sits down. If there is a tie, both people in the pair remain standing. Any individual not part of a pair
remains standing. Continue doing this until only one person remains standing or all persons standing
have the same birthday. Anyone still standing has the earliest birthday.
III. Beginning with the number 1, ask if anyone was born on that day of any month. Continue with the
numbers 2, 3, and so on until a positive response is received. If only one person responds, that person
has the earliest birthday. If more than one person responds, determine which person was born in the
earliest month, and that person or those persons have the earliest birthday.
(A) I only
(B) II only
(C) I and II
(D) II and III
2. A certain game keeps track of the maximum and minimum scores obtained so far. If num represents the most
recent score obtained, which of the following algorithms correctly updates the values of the maximum and the
minimum?
If num is greater than the minimum, set the minimum equal to num. Otherwise, if num is greater
(A)
than the maximum, set the maximum equal to num.
If num is less than the minimum, set the minimum equal to num. Otherwise, if num is greater than
(B)
the maximum, set the maximum equal to num.
If num is less than the minimum, set the minimum equal to num. Otherwise, if num is less than the
(C)
maximum, set the maximum equal to num.
If num is greater than the minimum, set the minimum equal to num. Otherwise, if num is less than
(D)
the maximum, set the maximum equal to num.
Term 1 - Mock 1
3. The grid below contains a robot represented as a triangle, initially facing right. 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 <MISSING CODE> can be used to move the robot to the gray square?
Term 1 - Mock 1
Term 1 - Mock 1
4. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
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 to for apartments that meet certain criteria.
(A)
(B)
(C)
(D)
Term 1 - Mock 1
5. The variable age is to be used to represent a person’s age, in years. Which of the following is the most
appropriate data type for age ?
(A) Boolean
(B) number
(C) string
(D) list
6. The variable isOpen is to be used to indicate whether or not a store is currently open. Which of the following is
the most appropriate data type for isOpen ?
(A) Boolean
(B) number
(C) string
(D) list
7. A teacher is writing a code segment that will use variables to represent a student’s name and whether or not the
student is currently absent. Which of the following variables are most appropriate for the code segment?
(A) A string variable named s and a Boolean variable named a
(B) A string variable named s and a numeric variable named n
(C) A string variable named studentName and a Boolean variable named isAbsent
(D) A string variable named studentName and a numeric variable named numAbsences
8. In a certain game, the integer variable bonus is assigned a value based on the value of the integer variable
score.
• If score is greater than 100, bonus is assigned a value that is 10 times score.
• If score is between 50 and 100 inclusive, bonus is assigned the value of score.
• If score is less than 50, bonus is assigned a value of 0.
Which of the following code segments assigns bonus correctly for all possible integer values of score ?
Term 1 - Mock 1
Term 1 - Mock 1
bonus ← score * 10
}
ELSE
{
bonus ← score
}
}
9. The cost of a customer’s electricity bill is based on the number of units of electricity the customer uses.
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)
(B)
(C)
(D)
Term 1 - Mock 1
10. 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)
11. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
(B)
(C)
(D)
Term 1 - Mock 1
12. Directions: For the question or incomplete statement below, two of the suggested answers are correct. For
this question, 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.
Which of the following are benefits of using well-named variables in a computer program?
13. The following table shows the value of expression based on the values of input1 and input2.
Which of the following expressions are equivalent to the value of expression as shown in the table?
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.
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?
Term 1 - Mock 1
Term 1 - Mock 1
15. The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially
facing toward the top of the grid.
Term 1 - Mock 1
Which of the following code segments will move the robot to the gray square along the path indicated by the
arrows?
Term 1 - Mock 1
(A)
(B)
(C)
(D)
Term 1 - Mock 1
If the variables onTime and absent both have the value false, what is displayed as a result of running the code
segment?
(A) Is anyone there?
(B) Better late than never.
(C) Hello. Is anyone there?
(D) Hello. Better late than never.
17. The code fragment below is intended to display "odd" if the positive number num is odd.
Which of the following can be used to replace <MISSING CONDITION> so that the code fragment will work as
intended?
(A) (num MOD 1) = 0
(B) (num MOD 1) = 1
(C) (num MOD 2) = 0
(D) (num MOD 2) = 1
Term 1 - Mock 1
18. The diagram below shows a circuit composed of two logic gates labeled OR and AND. Each gate takes two inputs
and produces a single output.
If the inputs A and C are both true, which of the following best describes the output of the AND gate?
(A) The output will be true no matter what the value of input B is.
(B) The output will be false no matter what the value of input B is.
(C) The output will be true if input B is true; otherwise it will be false.
(D) The output will be false if input B is true; otherwise it will be true.
A student’s overall course grade in a certain class is based on the student’s scores on individual assignments. The course
grade is calculated by dropping the student’s lowest individual assignment score and averaging the remaining scores.
For example, if a particular student has individual assignment scores of 85, 75, 90, and 95, the lowest score (75) is
dropped. The calculated course grade is .
19. A programmer is writing a program to calculate a student’s course grade using the process described. The
programmer has the following procedures available.
The student’s individual assignment scores are stored in the list scores. Which of the following can be used to
calculate a student’s course grade and store the result in the variable finalGrade?
Term 1 - Mock 1
Term 1 - Mock 1
20. The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the
center square and facing toward the top of the grid.
The following code segment is used to move the robot in the grid.
count 1
REPEAT 4 TIMES
{
REPEAT count TIMES
{
MOVE_FORWARD()
}
ROTATE_LEFT()
count ← count + 1
}
Which of the following code segments will move the robot from the center square along the same path as the code
segment above?
Term 1 - Mock 1
count 0
REPEAT 4 TIMES
{
count ← count + 1
REPEAT count TIMES
(A) {
MOVE_FORWARD()
}
ROTATE_LEFT()
}
count 0
REPEAT 4 TIMES
{
count ← count + 1
ROTATE_LEFT()
(B) REPEAT count TIMES
{
MOVE_FORWARD()
}
}
count 0
REPEAT 4 TIMES
{
REPEAT count TIMES
{
(C) ROTATE_LEFT()
}
MOVE_FORWARD()
count ← count + 1
}
count 0
REPEAT 4 TIMES
{
ROTATE_LEFT()
REPEAT count TIMES
(D) {
MOVE_FORWARD()
}
count ← count + 1
}
Term 1 - Mock 1
21. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially
facing right.
Which of the following code segments will move the robot to the gray square?
Term 1 - Mock 1
(A)
(B)
(C)
(D)
22. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
The code segment below is intended to display all multiples of 5 between the values and , inclusive.
For example, if has the value and has the value , the code segment should display the values
, , , and . Assume that and are multiples of 5 and that is less than .
Which of the following could replace in line 2 so that the code segment works as
intended?
Term 1 - Mock 1
(A)
(B)
(C)
(D)
23. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
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 , which evaluates to if the robot is in the
gray square and evaluates to otherwise.
Which of the following replacements for can be used to move the robot to the gray square?
Term 1 - Mock 1
(A)
(B)
(C)
(D)
Term 1 - Mock 1
Which of the following best describes the result of running the program code?
(A) The number 0 is displayed.
(B) The number 6 is displayed.
(C) The number 10 is displayed.
(D) Nothing is displayed; the program results in an infinite loop.
Term 1 - Mock 1
25. Consider the following code segment, where exam and presentation are integer variables and grade is
a string variable.
Under which of the following conditions will the value "C" be assigned to the variable grade ?
(A) When the value of exam is 70 and the value of presentation is 50
(B) When the value of exam is 70 and the value of presentation is 80
Term 1 - Mock 1
Term 1 - Mock 1
27. A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display the
number of elements in the list that have a value greater than 100. The algorithm uses the variables count and
position. Steps 3 and 4 are missing.
Which of the following could be used to replace steps 3 and 4 so that the algorithm works as intended?
Step 3
Increase the value of position by 1.
(A)
Step 4
Repeat steps 2 and 3 until the value of count is greater than 100.
Step 3
Increase the value of position by 1.
(B)
Step 4
Repeat steps 2 and 3 until the value of position is greater than n.
Step 3
Repeat step 2 until the value of count is greater than 100.
(C)
Step 4
Increase the value of position by 1.
Step 3
Repeat step 2 until the value of position is greater than n.
(D)
Step 4
Increase the value of count by 1.
Term 1 - Mock 1
28. A programmer wants to determine whether a score is within 10 points of a given target. For example, if the target is
50, then the scores 40, 44, 50, 58, and 60 are all within 10 points of the target, while 38 and 61 are not.
Which of the following Boolean expressions will evaluate to true if and only if score is within 10 points
of target ?
(A) (score ≤ target + 10) AND (target + 10 ≤ score)
(B) (target + 10 ≤ score) AND (score ≤ target - 10)
(C) (score ≤ target - 10) AND (score ≤ target + 10)
(D) (target - 10 ≤ score) AND (score ≤ target + 10)
29. A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display true
if the value target appears in the list more than once and to display false otherwise. The algorithm uses the
variables position and count. Steps 4 and 5 are missing.
Which of the following could be used to replace steps 4 and 5 so that the algorithm works as intended?
Term 1 - Mock 1
Step 4
Repeat steps 2 and 3 until the value of position is greater than n.
(A) Step 5
If count is greater than or equal to 2, display true. Otherwise, display
false.
Step 4
Repeat steps 2 and 3 until the value of position is greater than n.
(B) Step 5
If count is greater than or equal to position, display true.
Step 4
Repeat steps 2 and 3 until the value of count is greater than 2.
(C) Step 5
If position is greater than or equal to n, display true. Otherwise,
display false.
Step 4
Repeat steps 2 and 3 until the value of count is greater than n.
(D) Step 5
If count is greater than or equal to 2, display true. Otherwise, display
false.
30. Let n be an integer value. Which of the following expressions evaluates to true if and only if n is a two-digit
integer (i.e., in the range from 10 to 99, inclusive)?
Term 1 - Mock 1
A large spreadsheet contains the following information about local restaurants. A sample portion of the spreadsheet is
shown below.
C D E
A B
Number of Average Accepts
Restaurant Name Price Range
Customer Ratings Customer Rating Credit Cards
1 Joey Calzone’s Pizzeria lo 182 3.5 false
2 78th Street Bistro med 41 4.5 false
3 Seaside Taqueria med 214 4.5 true
4 Delicious Sub Shop II lo 202 4.0 false
5 Rustic Farm Tavern hi 116 4.5 true
6 ABC Downtown Diner med 0 -1.0 true
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.
31. 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?
(A) (avgRating ≥ 4.0) AND ((prcRange = "lo") AND (prcRange = "med"))
32. To qualify for a particular scholarship, a student must have an overall grade point average of 3.0 or above and must
have a science grade point average of over 3.2. Let overallGPA represent a student’s overall grade point
average and let scienceGPA represent the student’s science grade point average. Which of the following
expressions evaluates to true if the student is eligible for the scholarship and evaluates to false otherwise?
Term 1 - Mock 1
33. A flowchart is a way to visually represent an algorithm. The flowchart below uses the following building blocks.
Term 1 - Mock 1
(A) 5
(B) 15
(C) 1 2 3 4
(D) 1 2 3 4 5
Which of the following replacements for <MISSING CONDITION> will result in an infinite loop?
(A) j = 6
(B) j ≥ 6
(C) j = 7
(D) j > 7
Term 1 - Mock 1
35. 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 true ?
(A) A = true, B = true, C = true, D = false
(B) A = true, B = false, C = false, D = true
Term 1 - Mock 1
36. The following grid contains a robot represented as a triangle, which is initially facing right.
The following code segment is intended to move the robot to the gray square.
<MISSING STATEMENT>
{
REPEAT 4 TIMES
{
MOVE_FORWARD()
ROTATE_RIGHT()
}
ROTATE_LEFT()
MOVE_FORWARD()
ROTATE_RIGHT()
}
Which of the following can be used as a replacement for <MISSING STATEMENT> so that the code segment
works as intended?
Term 1 - Mock 1
37. A code segment is intended to transform the list utensils so that the last element of the list is moved to the
beginning of the list.
Term 1 - Mock 1
38. The following grid contains a robot represented as a triangle. The robot is initially facing right.
Which of the following code segments can be used to move the robot to the gray square along the path indicated by
the arrows?
Term 1 - Mock 1
(A)
(B)
(C)
Term 1 - Mock 1
(D)
39. The following grid contains a robot represented as a triangle, which is 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.
Which of the following code segments can be used to move the robot to the gray square?
Term 1 - Mock 1
REPEAT 3 TIMES
{
MOVE_FORWARD()
}
REPEAT 2 TIMES
{
(A) MOVE_FORWARD()
}
REPEAT 3 TIMES
{
MOVE_FORWARD()
}
REPEAT 8 TIMES
{
(B) MOVE_FORWARD()
}
REPEAT 3 TIMES
{
MOVE_FORWARD()
}
ROTATE_LEFT()
REPEAT 2 TIMES
{
(C) MOVE_FORWARD()
}
ROTATE_LEFT()
REPEAT 3 TIMES
{
MOVE_FORWARD()
}
REPEAT 3 TIMES
{
MOVE_FORWARD()
}
ROTATE_LEFT()
REPEAT 2 TIMES
{
(D) MOVE_FORWARD()
}
ROTATE_RIGHT()
REPEAT 3 TIMES
{
MOVE_FORWARD()
}
Term 1 - Mock 1
40. 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.
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?
IF(CAN_MOVE(left))
{
(A) ROTATE_LEFT()
MOVE_FORWARD()
}
IF(CAN_MOVE(forward))
{
(B) MOVE_FORWARD()
ROTATE_LEFT()
}
IF(CAN_MOVE(left))
{
(C) ROTATE_LEFT()
}
MOVE_FORWARD()
IF(CAN_MOVE(forward))
{
MOVE_FORWARD()
}
(D) ELSE
{
ROTATE_LEFT()
}
Term 1 - Mock 1
41. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.
A gate is a type of logic gate that produces an output of only when both of its two inputs are
. Otherwise, the gate produces an output of . Which of the following Boolean expressions correctly
models a gate with inputs and ?
(A)
(B)
(C)
(D)
42. Three teams (Team A, Team B, and Team C) are participating in a trivia contest. Let scoreA represent the
number of correct questions for Team A, scoreB represent the number of correct questions for Team B, and
scoreC represent the number of correct questions for Team C. Assuming no two teams get the same number of
correct questions, which of the following code segments correctly displays the team with the highest number of
correct questions?
Term 1 - Mock 1
(A)
(B)
(C)
Term 1 - Mock 1
(D)
Term 1 - Mock 1
43. A numeric test score is to be converted to a letter grade of A, B, or C according to the following rules: A score
greater than 90 is considered an A; a score between 80 and 90, inclusive, is considered a B; and any other score is
considered a C.
Which of the following code segments will assign the correct letter grade to grade based on the value of the
variable score ?
I.
Term 1 - Mock 1
II.
Term 1 - Mock 1
III.
(A) II only
(B) I and II only
(C) I and III only
(D) II and III only
44. In a certain country, a person must be at least 16 years old to drive a car and must be at least 18 years old to vote.
The variable age represents the age of a person as an integer.
Which of the following expressions evaluates to true if the person is old enough to drive but not old enough to
vote, and evaluates to false otherwise?
Term 1 - Mock 1
PROCEDURE proc1(str)
{
DISPLAY(str)
DISPLAY("happy")
}
PROCEDURE proc2(str1, str2)
{
proc1(str2)
DISPLAY(str1)
}
Term 1 - Mock 1
46. The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the
bottom-left square of the grid and facing toward the top of the grid.
Code for the procedure Mystery is shown below. Assume that the parameter p has been assigned a positive integer
value (e.g., 1, 2, 3, …).
Term 1 - Mock 1
(A)
(B)
(C)
(D)