Variables and Data Types
Control Structures
Functions and Parameters
Lists and Iteration
Boolean Logic & Conditionals
100

Which of the following is a valid variable assignment in pseudocode? 

A) x ← 5
B) 5 ← x
C) DISPLAY x = 5
D) SET 5 TO x

What is (A):  x ← 5

100

What does an IF statement do?
A) Test a condition
B) Repeat code

What is (A): Test a Condition

100

What is a function used for?
A) Reuse code
B) Repeat loops
C) Store data
D) Define variables

What is (A): Reuse Code

100

What is the first element in the list list ← [5, 6, 7]?
A) 5
B) 6
C) 7
D) 1

What is (A): 5

100

What does true AND false evaluate to?
A) true
B) false
C) Error
D) null

What is (B): False

200

Which of the following is a benefit of using a list as a data abstraction in a program? 

A. Lists often allow their size to be easily updated to hold as many data values as needed.

B. Lists convert all elements to strings so that they can be inspected character-by-character.

C. Lists prevent duplicate data values from appearing in the list.

D. Lists are used to store all input data so that there is a running record of all user input.

What is (A): Lists often allow their size to be easily updated to hold as many data values as needed.

200

 Predict the output:

x ← 5  
y ← 10  
IF x > y OR y > 8 THEN      
DISPLAY("Pass") 
 ELSE      
DISPLAY("Fail")  


A) Pass
B) Fail
C) Error
D) 10

What is (A): Pass

200

What does this display?

FUNCTION mystery(x)      
RETURN x * x - x  
DISPLAY(mystery(5))  


A) 20
B) 25
C) 10
D) 15

What is (A): 20

200

Consider the following code segment.

firstList ←← ["guitar", "drums", "bass"]

secondList ←← ["flute", "violin"]

thirdList ←← [ ]

thirdList ←← firstList

firstList ←← secondList

secondList ←← thirdList

What are the contents of secondList after the code segment is executed?

A [ ]

B. ["guitar", "drums", "bass"]

C. ["flute", "violin"]

D. ["flute", "violin", "guitar", "drums", "bass"]

What is (B): ["guitar", "drums", "bass"] 

200

If a list contains n items, how many comparisons would a linear search make in the worst case?
A) 1
B) log n
C) n
D) n²

What is (C): n

300

What is the value of x after executing the following code?

x ← 3  
x ← x + 4  


A) 3
B) 4
C) 7
D) Error

What is (C): 7

300

What is the result of

x ← 5  
IF x > 2 THEN DISPLAY("Yes")  
ELSE DISPLAY("No") 


What is: Yes

300

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?

A. A simulation of flipping a fair coin

B. A simulation of rolling a fair die (with sides numbered 1 through 6)

C. A simulation of the temperature in a location over time

D. A simulation of traffic patterns on a road

What is (A): A simulation of flipping a fair coin

300

What does APPEND(list, 10) do?
A) Adds 10 to the end of the list
B) Removes 10 from the list
C) Replaces the first element with 10
D) Sorts the list

What is (A): Adds 10 to the end of the list

300


To attend a particular camp, a student must be either at least 13 years old or in grade 9 or higher, but must not yet be 18 years old. Let age represent a student’s age and let grade represent the student’s grade level. Which of the following expressions evaluates to true if the student is eligible to attend the camp and evaluates to false otherwise?

Responses


A

((age ≥ 13) OR (grade ≥ 9)) AND (age ≤ 18)


B

((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)


C

((age ≥ 13) OR (grade ≥ 9)) OR (age ≤ 18)


D

((age ≥ 13) OR (grade ≥ 9)) OR (age < 18)


What is (B): ((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)

400

Study the code segment below. Values of x and y will be displayed multiple times during the
running of the program. From the list of possible outputs, choose two of the outputs that are
impossible for this code to produce.

x ← 0
REPEAT_UNTIL( x = 3 )
y ← 0
x ← x+1
REPEAT_UNTIL ( y = 3 ){
y ← y+1
DISPLAY( x + ", " + y)
}
}

What is

 - 0,0
- 2,4 

400

A group of programming instructions. They're also known as methods or functions, depending on the programming language. You can use a procedure to use the same set of instructions, again and again, without having to rewrite it into your code.

What is a procedure

400

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

What is (C): A string variable named studentName and a Boolean variable named isAbsent 

400

Tiffany is writing a program to help manage a bake sale. She writes the following code which
prompts the user to enter the total number of items a person is buying and then a loop repeatedly
prompts for the cost of each item. She wrote the code but there is a problem: it runs in an infinite
loop. How can Tiffany change her code so it doesn't loop forever?

0 var numItems = promptNum("How many items?");
1 var total = 0;
2 while (numItems > 0){
3 total = total + promptNum("Enter next item price");
4 }
5 console.log("The total is" + total);

What is Add after line 3: numItems = numItems - 1; 

400


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?

Responses


A

(overallGPA > 3.0) AND (scienceGPA > 3.2)


B

(overallGPA > 3.0) AND (scienceGPA ≥ 3.2)


C

(overallGPA ≥ 3.0) AND (scienceGPA > 3.2)


D

(overallGPA ≥ 3.0) AND (scienceGPA ≥ 3.2)


What is (C): (overallGPA ≥ 3.0) AND (scienceGPA > 3.2)

500

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

What is (C): A string variable named studentName and a Boolean variable named isAbsent 

500

Assume that the Boolean variable hot is assigned the value true and the Boolean variable humid is assigned the value false. Which of the following will display the value true ?

Select two answers. ("DISPLAY" is indented)

A. IF hot

DISPLAY hot AND humid

B. IF NOT hot

DISPLAY hot OR humid

C. IF hot OR humid

DISPLAY hot

D. IF hot AND humid

DISPLAY hot

What is:

B. IF NOT hot

DISPLAY hot OR humid

C. IF hot OR humid

DISPLAY hot

500

Which statement correctly calls a function named addNums with 2 and 3?
A) addNums(2, 3)
B) CALL 2, 3 TO addNums
C) addNums = 2 + 3
D) FUNCTION addNums(2, 3)
 

What is (A): addNums(2, 3) 

500

Which code sums values in a list?

sum ← 0  
FOR EACH num IN list      
sum ← sum + num  


A) It adds up all values
B) It multiplies values
C) It subtracts values
D) It divides values

What is (A): It adds up all values

500

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)

What is (D): (target - 10 ≤ score) AND (score ≤ target + 10)