AP CSP Unit 4: Variables, Expressions, and Lists
34 multiple-choice questions on AP Computer Science Principles Unit 4, Variables, Expressions, and Lists, organized by topic. They are not tied to any one class or teacher: they follow the College Board course framework. Learn the 7 key terms with the flashcards first, then test yourself. Every answer comes with a short explanation.
Take the practice test · Flashcards · All study tools
What it covers
- 4.1 Variables and assignment
- 4.2 Expressions, strings, and operators
- 4.3 Boolean expressions and conditionals
- 4.4 Lists
Key terms
4.4 Lists
- Assignment operator (←)
- Stores the value of an expression in a variable
- MOD
- Returns the remainder of a division
- Boolean expression
- An expression that evaluates to true or false
- String concatenation
- Joining strings end to end
- List
- An ordered sequence of elements
- APPEND / INSERT / REMOVE
- List operations that add to the end, insert at an index, or delete at an index
- Data abstraction
- Managing complexity by naming a collection of data without referring to its details
Sample practice questions
In AP pseudocode, what does the statement a ← 7 do?
- It assigns the value 7 to the variable a
- It checks whether the variable a equals 7
- It displays the value 7 next to the name a
- It adds 7 to the current value stored in a
Answer: A. It assigns the value 7 to the variable a The arrow is the assignment operator.
What is the value of 17 MOD 5 in AP pseudocode?
- 3
- 3.4
- 2
- 5
Answer: C. 2 MOD gives the remainder after division.
What is the value of (5 > 3) AND (2 > 4)?
- true
- false
- 5
- 2
Answer: B. false AND requires both conditions to be true.
In AP pseudocode, list indices start at
- 0
- 1
- −1
- any number the programmer chooses
Answer: B. 1 The AP CSP reference sheet uses index 1 for the first element.
What is displayed? a ← 3; b ← a; a ← 5; DISPLAY(b)
- 5
- 3
- 8
- a
Answer: B. 3 b received a copy of a's value (3) before a changed.
What is the value of 10 MOD 2?
- 5
- 0
- 2
- 1
Answer: B. 0 10 divides evenly by 2.
What is the value of NOT (3 = 3) OR (4 < 5)?
- false
- 3
- 4
- true
Answer: D. true NOT (3 = 3) is false, but 4 < 5 is true, so OR gives true.
Given myList ← [10, 20, 30, 40], what is myList[2]?
- 30
- 10
- An error
- 20
Answer: D. 20 Index 1 is 10 and index 2 is 20.
What is displayed? x ← 4; x ← x + 2; x ← x * 3; DISPLAY(x)
- 10
- 14
- 12
- 18
Answer: D. 18 x becomes 6, then 18.
Which expression evaluates to true if the number n is odd?
- n MOD 2 = 0
- n / 2 = 1
- n MOD 2 = 1
- n MOD 1 = 2
Answer: C. n MOD 2 = 1 Odd positive numbers leave remainder 1 when divided by 2.
More AP Computer Science Principles
- Unit 1: Creative Development
- Unit 2: Binary and Data Representation
- Unit 3: Data Compression and Using Data
- Unit 5: Iteration, Procedures, and Libraries
- Unit 6: Algorithms, Efficiency, and Simulations
- Unit 7: The Internet and Computer Systems
- Unit 8: Impact of Computing
- Unit 9: Legal, Ethical, and Safe Computing
Studying for a test in your own class? Make a practice test from your class notes.