Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Semester Final Review

Total questions: 69

Worksheet time: 35mins

Name
Class
Date
1.

What number will be output?

a ← 5

b ← 10

c ← a + b

a ← 5 + c

b ← 10 + a

c ← a + b + c

DISPLAY (c)

a)

65

b)

10

c)

15

d)

20

2.

bat <- 20

super <- 10

bat <- bat + super

bat <- bat + 20

bat <- bat + super

DISPLAY(bat)

a)

30

b)

20

c)

60

d)

40

3.

Boolean Value

(4+5) < (5+5)

a)

True

b)

False

c)

c

d)

None of the above

4.

Boolean Value

(6 * 6) > (7 * 7)

a)

True

b)

False

c)

48

d)

36

5.

Write the expressions:

a)

False, False, False

b)

True, False, False

c)

False, True, False

d)

True, True, True

6.

Find the Boolean Value:

a)

True, False

b)

False, True

c)

True True

d)

False, False

7.

(10 > 5) AND (5 < 10)

a)

True

b)

False

8.

NOT (5 + 10 = 15)

a)

False

b)

True

9.

(15 + 5 =25) And (5 + 10 = 15)

a)

True

b)

False

10.

NOT (False)

a)

False

b)

True

11.

(22 + 78 + 100)

a)

True

b)

False

12.

True AND False

a)

False

b)

True

13.

True AND True

a)

True

b)

False

14.

True OR False

a)

True

b)

False

15.

False OR False

a)

False

b)

True

16.

True AND Not (False)

a)

True

b)

False

17.

True or False

a)

True

b)

False

18.

False or False

a)

True

b)

False

19.

False AND True

a)

True

b)

False

20.

False AND False

a)

True

b)

False

21.

-57>57

a)

True

b)

False

22.

2.15>1.23

a)

True

b)

False

23.

Which of the following best describes procedural abstraction in coding?

a)

A programming paradigm focused on the use of events to trigger code execution.

b)

The practice or writing code without using functions or procedures.

c)

The process of creating complex data structures

d)

The technique of breaking down a program into smaller, manageable pieces.

24.

What is a conditional statement in programming?

a)

A statement that is used to implement detail removal and generalization in order to reduce the complexity and allow for reuse of code segments.

b)

A statement that is always executed regardless of the program's flow.

c)

A statement that allows a program to make decisions and execute different code based on certain conditions.

d)

A statement used for declaring variables and assigning values such as numbers, text, and Booleans.

25.

In programming, what does the term "library" refer to?

a)

A self-contained module or collection of functions that provides specific functionality.

b)

A physical collection of books and resources related to programming

c)

The process of finding and fixing errors in a program.

d)

The main program that controls the execution of code in a computer.

26.

Which of the following statements about algorithms is true?

a)

Algorithms have a fixed implementation and cannot be modified once created

b)

Algorithms are only used in computer programming and have no real-world applications.

c)

An algorithm is a physical device used to perform calculations

d)

An algorithm is a step-by-step set of instructions to solve a problem or perform a task.

27.

REPEAT and REPEAT UNTIL are examples of:

a)

Iteration

b)

Boolean Value

c)

Functionality

d)

Library

28.

IF and IF/ELSE are examples of:

a)

Selection

b)

Iteration

c)

Boolean Value

d)

Purpose

29.

Pre-Build set of procedures are:

a)

Library

b)

Procedure

c)

Selection

d)

Functionality

30.

TRUE, FALSE

a)

Algorithm

b)

Boolean Value

c)

Purpose

d)

Selection

31.

A set of Instructions are:

a)

Algorithm

b)

Purpose

c)

Selection

d)

Abstraction Components

32.

What a program does and how it does it

a)

Functionality

b)

Purpose

c)

Selection

d)

Iteration

33.

Detail removal and generalization

a)

Iteration

b)

Purpose

c)

Abstraction components

d)

Selection

34.

0!

a)

1

b)

2

c)

3

d)

4

35.

5!

a)

5

b)

120

c)

60

d)

55

36.

3!

a)

3

b)

4

c)

6

d)

9

37.

Typing in a word:

a)

Input

b)

Output

38.

Program Branching

a)

Selection

b)

Variable

c)

Output

d)

Input

39.

Container that holds a value is a

a)

Input

b)

Variable

c)

Iteration

40.

True or false value is a:

a)

Selection

b)

Boolean Value

c)

Variable

d)

Abstraction

41.

Generalization and detail removal are:

a)

Output

b)

Variable

c)

Boolean

d)

Abstraction

42.

Which of the following is true about variables?

a)

is required when a program decides to branch or not

b)

A variable is an abstraction inside a program that can hold a value

c)

A variable repeats a portion of code a specified number of times

d)

Is a named group of programming instructions

43.

17 MOD 5 = 3

a)

True

b)

False

44.

Which of the following expressions represents the value stored in the variable x as a result of executing the

program?

a)

2 * 3 * 3 * 3

b)

2 x 4 x 4 * 4

c)

2 x 3 x 3 x 3 x 3

d)

2 x 4 x 4 x 4 x 4

45.

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?

a)

b)

c)

d)

46.

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

c)

A = false, B = true, C = true, D = true

d)

A = false, B = false, C = true, D = true

47.

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?

a)

Program I correctly moves the robot to the gray square, but program II does not.

b)

Program II correctly moves the robot to the gray square, but program I does not.

c)

Both program I and program II correctly move the robot to the gray square

d)

Neither program I nor program II correctly moves the robot to the gray square.

48.

Which of the following actions are generally helpful in program development?

a)

I and II Only

b)

I and III only

c)

II and III only

d)

I, II, and III

49.

Which of the following code segments correctly displays the cost of a ticket?

a)

b)

c)

d)

50.

Which of the following can be used as a step 3 so that the algorithm works as intended?

a)

Step 3: Display the remainder of number divided by 10 and store the remainder in number.

b)

Step 3: Display the remainder of number divided by 10 and store the integer quotient in number.

c)

Step 3: Display the integer quotient of number divided by 10 and store the remainder in number

d)

Step 3: Display the integer quotient of number divided by 10 and store the integer quotient in number.

51.

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

a)

Program A and program B display identical values in the same order.

b)

Program A and program B display the same values in different orders.

c)

Program A and program B display the same number of values, but the values differ.

d)

Program B displays one more value than program A.

52.

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?

a)

Inserting index ← index + 1 between lines 6 and 7

b)

Inserting index ← index + 1 between lines 7 and 8

c)

Inserting index ← index - 1 between lines 6 and 7

d)

Inserting index ← index - 1 between lines 7 and 8

53.

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?

a)

b)

c)

d)

54.

Which of the following code segments can be used to simulate the behavior of the spinner?

a)

b)

c)

d)

55.

Which of the following statements is equivalent to the algorithm in the flowchart?

a)

b)

c)

d)

56.

Which of the following describes the result of executing the program?

a)

The program displays the sum of the even integers from 2 to 10.

b)

The program displays the sum of the even integers from 2 to 20

c)

The program displays the sum of the odd integers from 1 to 9

d)

The program displays the sum of the odd integers from 1 to 19.

57.

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 ?

a)

I and II only

b)

I and III only

c)

II and III only

d)

I, II, and III

58.

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?

a)

Too high

b)

in range

c)

too low

d)

out of range

59.

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?

a)

finalGrade ← Sum (scores) / LENGTH (scores)

finalGrade ← finalGrade - Min (scores)

b)

finalGrade ← Sum (scores) / (LENGTH (scores) - 1)

finalGrade ← finalGrade - Min (scores)

c)

finalGrade ← Sum (scores) - Min (scores) finalGrade ← finalGrade / LENGTH (scores)

d)

finalGrade ← Sum (scores) - Min (scores) finalGrade ← finalGrade / (LENGTH (scores) - 1)

60.

Which of the following CANNOT be determined from this data alone?

a)

For a given student, the value of the highest assignment score

b)

For a given student, the value of the lowest assignment score

c)

For a given student, the change in course grade as a result of dropping the lowest score

d)

The proportion of students who improved their course grade as a result of dropping the lowest score

61.

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)

b)

c)

d)

62.

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?

a)

Procedure Min (x, y), which returns the lesser of its two integer parameters

b)

Procedure Max (numList), which returns the maximum value in the list of integers numList

c)

Procedure MaxFour (w, x, y, z), which returns the greatest of its four integer parameters

d)

Procedure OverMax (numList, max), which returns the number of integers in numList that exceed the integer value max

63.

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?

a)

Lines 1 and 2 should be interchanged.

b)

Line 3 should be changed to REPEAT UNTIL (i ≥ 10).

c)

Lines 5 and 6 should be interchanged.

d)

No change is needed; the program works correctly.

64.

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)

65.

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?

a)

b)

c)

d)

66.

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?

a)

AnyPairs ("bat", "cat", "rat")

b)

AnyPairs ("bat", "bat", "rat")

c)

AnyPairs ("bat", "cat", "bat")

d)

AnyPairs ("bat", "cat", "cat")

67.

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.

a)

b)

c)

d)

68.

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.

a)

Multiply (2, 5)

b)

Multiply (2, -5)

c)

Multiply (-2, 5)

d)

Multiply (-2, -5)

69.

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.

a)

b)

c)

d)