WorksheetsSemester Final Review
Total questions: 69
Worksheet time: 35mins
What number will be output?
a ← 5
b ← 10
c ← a + b
a ← 5 + c
b ← 10 + a
c ← a + b + c
DISPLAY (c)
65
10
15
20
bat <- 20
super <- 10
bat <- bat + super
bat <- bat + 20
bat <- bat + super
DISPLAY(bat)
30
20
60
40
Boolean Value
(4+5) < (5+5)
True
False
c
None of the above
Boolean Value
(6 * 6) > (7 * 7)
True
False
48
36
Write the expressions:
False, False, False
True, False, False
False, True, False
True, True, True
Find the Boolean Value:
True, False
False, True
True True
False, False
(10 > 5) AND (5 < 10)
True
False
NOT (5 + 10 = 15)
False
True
(15 + 5 =25) And (5 + 10 = 15)
True
False
NOT (False)
False
True
(22 + 78 + 100)
True
False
True AND False
False
True
True AND True
True
False
True OR False
True
False
False OR False
False
True
True AND Not (False)
True
False
True or False
True
False
False or False
True
False
False AND True
True
False
False AND False
True
False
-57>57
True
False
2.15>1.23
True
False
Which of the following best describes procedural abstraction in coding?
A programming paradigm focused on the use of events to trigger code execution.
The practice or writing code without using functions or procedures.
The process of creating complex data structures
The technique of breaking down a program into smaller, manageable pieces.
What is a conditional statement in programming?
A statement that is used to implement detail removal and generalization in order to reduce the complexity and allow for reuse of code segments.
A statement that is always executed regardless of the program's flow.
A statement that allows a program to make decisions and execute different code based on certain conditions.
A statement used for declaring variables and assigning values such as numbers, text, and Booleans.
In programming, what does the term "library" refer to?
A self-contained module or collection of functions that provides specific functionality.
A physical collection of books and resources related to programming
The process of finding and fixing errors in a program.
The main program that controls the execution of code in a computer.
Which of the following statements about algorithms is true?
Algorithms have a fixed implementation and cannot be modified once created
Algorithms are only used in computer programming and have no real-world applications.
An algorithm is a physical device used to perform calculations
An algorithm is a step-by-step set of instructions to solve a problem or perform a task.
REPEAT and REPEAT UNTIL are examples of:
Iteration
Boolean Value
Functionality
Library
IF and IF/ELSE are examples of:
Selection
Iteration
Boolean Value
Purpose
Pre-Build set of procedures are:
Library
Procedure
Selection
Functionality
TRUE, FALSE
Algorithm
Boolean Value
Purpose
Selection
A set of Instructions are:
Algorithm
Purpose
Selection
Abstraction Components
What a program does and how it does it
Functionality
Purpose
Selection
Iteration
Detail removal and generalization
Iteration
Purpose
Abstraction components
Selection
0!
1
2
3
4
5!
5
120
60
55
3!
3
4
6
9
Typing in a word:
Input
Output
Program Branching
Selection
Variable
Output
Input
Container that holds a value is a
Input
Variable
Iteration
True or false value is a:
Selection
Boolean Value
Variable
Abstraction
Generalization and detail removal are:
Output
Variable
Boolean
Abstraction
Which of the following is true about variables?
is required when a program decides to branch or not
A variable is an abstraction inside a program that can hold a value
A variable repeats a portion of code a specified number of times
Is a named group of programming instructions
17 MOD 5 = 3
True
False
Which of the following expressions represents the value stored in the variable x as a result of executing the
program?
2 * 3 * 3 * 3
2 x 4 x 4 * 4
2 x 3 x 3 x 3 x 3
2 x 4 x 4 x 4 x 4
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?
which of the following input values will the circuit have an output of true ?
A = true, B = true, C = true, D = false
A = true, B = false, C = false, D = true
A = false, B = true, C = true, D = true
A = false, B = false, C = true, D = 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 program?
Program I correctly moves the robot to the gray square, but program II does not.
Program II correctly moves the robot to the gray square, but program I does not.
Both program I and program II correctly move the robot to the gray square
Neither program I nor program II correctly moves the robot to the gray square.
Which of the following actions are generally helpful in program development?
I and II Only
I and III only
II and III only
I, II, and III
Which of the following code segments correctly displays the cost of a ticket?
Which of the following can be used as a step 3 so that the algorithm works as intended?
Step 3: Display the remainder of number divided by 10 and store the remainder in number.
Step 3: Display the remainder of number divided by 10 and store the integer quotient in number.
Step 3: Display the integer quotient of number divided by 10 and store the remainder in number
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?
Program A and program B display identical values in the same order.
Program A and program B display the same values in different orders.
Program A and program B display the same number of values, but the values differ.
Program B displays one more value than program A.
While debugging the program, the student realizes that the loop never terminates. Which of the following changes can be made so that the program works as intended?
Inserting index ← index + 1 between lines 6 and 7
Inserting index ← index + 1 between lines 7 and 8
Inserting index ← index - 1 between lines 6 and 7
Inserting index ← index - 1 between lines 7 and 8
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 ()) { }
Which of the following replacements for can be used to move the robot to the gray square?
Which of the following code segments can be used to simulate the behavior of the spinner?
Which of the following statements is equivalent to the algorithm in the flowchart?
Which of the following describes the result of executing the program?
The program displays the sum of the even integers from 2 to 10.
The program displays the sum of the even integers from 2 to 20
The program displays the sum of the odd integers from 1 to 9
The program displays the sum of the odd integers from 1 to 19.
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 and II only
I and III only
II and III only
I, II, and III
Assume that the variable n has been initialized with an integer value, Which of the following is NOT a possible value displayed by the program?
Too high
in range
too low
out of range
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?
finalGrade ← Sum (scores) / LENGTH (scores)
finalGrade ← finalGrade - Min (scores)
finalGrade ← Sum (scores) / (LENGTH (scores) - 1)
finalGrade ← finalGrade - Min (scores)
finalGrade ← Sum (scores) - Min (scores) finalGrade ← finalGrade / LENGTH (scores)
finalGrade ← Sum (scores) - Min (scores) finalGrade ← finalGrade / (LENGTH (scores) - 1)
Which of the following CANNOT be determined from this data alone?
For a given student, the value of the highest assignment score
For a given student, the value of the lowest assignment score
For a given student, the change in course grade as a result of dropping the lowest score
The proportion of students who improved their course grade as a result of dropping the lowest score
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.
Consider the following procedure displayed in gray:
Which of the following code segments will move the robot to the gray square along the path indicated by the arrows?
A programmer notices the following two procedures in a library. The procedures do similar, but not identical, things.
• Procedure MaxTwo (x, y) returns the greater of its two integer parameters.
• Procedure MaxThree (x, y, z) returns the greatest of its three integer parameters.
Which of the following procedures is a generalization of the MaxTwo and MaxThree procedures?
Procedure Min (x, y), which returns the lesser of its two integer parameters
Procedure Max (numList), which returns the maximum value in the list of integers numList
Procedure MaxFour (w, x, y, z), which returns the greatest of its four integer parameters
Procedure OverMax (numList, max), which returns the number of integers in numList that exceed the integer value max
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.
Which change, if any, is needed for the program to work as intended?
Lines 1 and 2 should be interchanged.
Line 3 should be changed to REPEAT UNTIL (i ≥ 10).
Lines 5 and 6 should be interchanged.
No change is needed; the program works correctly.
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 ?
(score ≤ target + 10) AND (target + 10 ≤ score)
(target + 10 ≤ score) AND (score ≤ target - 10)
(score ≤ target - 10) AND (score ≤ target + 10)
(target - 10 ≤ score) AND (score ≤ target + 10)
Consider a game in which a player flips a fair coin three times. If all three coin flips have the same result (either all heads or all tails) the player wins. Otherwise, the player loses.
Which of the following code segments best simulates the behavior of the game?
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.
For which of the following procedure calls does the procedure NOT return the intended value?
AnyPairs ("bat", "cat", "rat")
AnyPairs ("bat", "bat", "rat")
AnyPairs ("bat", "cat", "bat")
AnyPairs ("bat", "cat", "cat")
Assume that the Boolean variable x is assigned the value true and the Boolean variable y is assigned the value false. Which of the following will display the value true ? Select two answers.
The following procedure is intended to return the value of x times y, where x and y are integers. Multiplication is implemented using repeated additions.
For which of the following procedure calls does the procedure NOT return the intended value?
Select two answers.
Multiply (2, 5)
Multiply (2, -5)
Multiply (-2, 5)
Multiply (-2, -5)
The procedure NumOccurrences is intended to count and return the number of times targetWord appears in the list wordList. The procedure does not work as intended.
For which of the following code segments will the call to NumOccurrences NOT return the intended value? Select two answers.
