All questions
Question 1
A bank account applies a bonus rule. Which statement correctly describes the final state of variable balance?
balance <- 80 // starting balance
deposit <- 20 // deposit amount
balance <- balance + deposit // after deposit
balance <- balance - 10 // monthly fee
balance <- balance + deposit // deposit repeated
balance <- balance + 5 // small bonus
- balance ends at 110
- balance ends at 95
- balance ends at 105
- balance ends at 115 (correct answer)
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding sequential modifications is crucial for tracking program state. In the provided pseudocode, balance starts at 80, increases by 20 (deposit) to 100, decreases by 10 (fee) to 90, increases by 20 again (repeated deposit) to 110, then increases by 5 (bonus) to 115. Choice D (balance ends at 115) is correct because the operations correctly modify balance through each step: 80 + 20 = 100, 100 - 10 = 90, 90 + 20 = 110, 110 + 5 = 115. Choice A (110) omits the final bonus, while Choice B (95) might result from missing the repeated deposit. Encourage students to trace variable changes line by line, noting that the same operation (like adding deposit) can be performed multiple times. Practice identifying patterns in variable modifications.
Question 2
A temperature converter runs this pseudocode. If the input value is 86, what will be the output value stored in celsius?
fahrenheit <- 86 // input temperature
celsius <- 0 // output temperature
celsius <- fahrenheit - 32 // subtract 32
celsius <- celsius * 5 // multiply by 5
celsius <- celsius / 9 // divide by 9
celsius <- celsius + 0 // keep value
- 30 (correct answer)
- 32
- 28
- 54
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work in sequence is crucial for implementing algorithms like temperature conversion. In the provided pseudocode, the variable celsius is initialized to 0 and modified through the Fahrenheit to Celsius conversion formula: (F - 32) × 5/9. Choice A (30) is correct because the operations correctly modify celsius: 86 - 32 = 54, then 54 * 5 = 270, then 270 / 9 = 30, and adding 0 keeps it at 30. Choice B (32) might result from an arithmetic error, while Choice C (28) could come from incorrect order of operations. Encourage students to trace variable changes line by line, especially when implementing mathematical formulas. Practice breaking complex formulas into simple steps to avoid errors in calculation order.
Question 3
A bank account starts at $100. Using the pseudocode below, what is the value of balance after executing the code?
balance <- 100 // starting money
deposit <- 40 // money added
withdrawal <- 25 // money taken out
balance <- balance + deposit // add deposit
balance <- balance - withdrawal // subtract withdrawal
balance <- balance + 10 // bonus added
- 115
- 125 (correct answer)
- 135
- 105
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, the variable balance is initialized to 100 and modified through operations: adding a deposit of 40, subtracting a withdrawal of 25, and adding a bonus of 10. Choice B (125) is correct because the operations correctly modify balance: 100 + 40 = 140, then 140 - 25 = 115, then 115 + 10 = 125. Choice C (135) is incorrect as it might result from forgetting to subtract the withdrawal, while Choice D (105) incorrectly applies only some operations. Encourage students to trace variable changes line by line, writing down the value after each assignment. Practice identifying the order of operations and ensure each assignment statement is executed in sequence.
Question 4
A shopping cart adds two items. Using the pseudocode below, what is the value of total after executing the code?
price <- 8 // dollars per item
quantity <- 3 // number of items
total <- 0 // running cart total
total <- total + price * quantity // add first item
total <- total + 5 * 2 // add second item
total <- total - 4 // apply discount
- 34
- 30 (correct answer)
- 24
- 40
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations, including arithmetic expressions. Understanding how assignments work with multiple operations is crucial for tracking program state. In the provided pseudocode, the variable total starts at 0 and is modified through operations: adding price * quantity (8 * 3 = 24), adding 5 * 2 = 10, then subtracting 4. Choice B (30) is correct because the operations correctly modify total: 0 + 24 = 24, then 24 + 10 = 34, then 34 - 4 = 30. Choice A (34) is incorrect as it omits the final discount subtraction, while Choice C (24) only accounts for the first item. Encourage students to trace variable changes line by line and pay attention to operator precedence in expressions. Reinforce the importance of understanding that each assignment completely replaces the previous value of the variable.
Question 5
Use this pseudocode: 1 balance=50; 2 deposit=30; 3 balance=balance+deposit; 4 withdrawal=10; 5 balance=balance-withdrawal; 6 deposit=20; 7 balance=balance+deposit; What is the value of variable balance after executing the code?
- 80
- 90 (correct answer)
- 70
- 60
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, balance starts at 50, then increases by 30 (deposit) to 80, decreases by 10 (withdrawal) to 70, and finally increases by 20 (deposit) to 90. Choice B (90)iscorrectbecausetracingthroughtheoperations:50+30=80,80−10=70,70+20=90.ChoiceC(70) is incorrect as it stops before the final deposit operation. Encourage students to trace variable changes line by line using a table to track each variable's value after each assignment statement.
Question 6
Use this pseudocode: 1 total=0; 2 price=5; 3 quantity=2; 4 total=total+(pricequantity); 5 price=4; 6 quantity=2; 7 total=total+(pricequantity); What is the value of variable total after executing the code?
- 16
- 18 (correct answer)
- 20
- 14
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, total starts at 0, then adds (5 × 2) = 10 to get 10, then adds (4 × 2) = 8 to get 18. Choice B (18)iscorrectbecausetheoperationscorrectlycalculate:0+10+8=18.ChoiceC(20) is incorrect and might result from misunderstanding the order of operations or making an arithmetic error. Encourage students to evaluate expressions within parentheses first and to track the running total after each addition operation.
Question 7
Use this pseudocode: 1 principal=1000; 2 rate=0.05; 3 time=2; 4 interest=principalrate; 5 interest=interesttime; 6 amount=principal+interest; What is the value of variable amount after executing the code?
- 1100 (correct answer)
- 1160
- 1120
- 1060
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, principal = 1000, rate = 0.05, time = 2, then interest = 1000 × 0.05 = 50, interest = 50 × 2 = 100, and amount = 1000 + 100 = 1100. Choice A (1100)iscorrectbecausethesimpleinterestformulacorrectlycalculates100 interest on 1000principal.ChoiceB(1160) is incorrect and might result from a compound interest calculation. Encourage students to trace each calculation step and understand the difference between simple and compound interest formulas.
Question 8
A simple interest calculator updates the rate. Using the pseudocode below, what is the value of interest after executing the code?
principal <- 500 // starting money
rate <- 0.04 // initial rate
time <- 2 // years
rate <- rate + 0.01 // rate increases
interest <- principal * rate // one-year interest
interest <- interest * time // total interest
- 40
- 50 (correct answer)
- 60
- 45
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how variable modifications affect subsequent calculations is crucial for financial computations. In the provided pseudocode, the rate variable is updated from 0.04 to 0.05 (adding 0.01), then interest is calculated using the new rate: 500 * 0.05 = 25 for one year, then multiplied by 2 years. Choice B (50) is correct because the operations correctly calculate: rate = 0.04 + 0.01 = 0.05, interest = 500 * 0.05 = 25, then interest = 25 * 2 = 50. Choice A (40) incorrectly uses the original rate, while Choice C (60) might result from a calculation error. Encourage students to trace variable changes before they are used in calculations. Emphasize that when a variable is modified, all subsequent uses of that variable will use the new value.
Question 9
Simple interest scenario: Refer to the pseudocode. If the input value is 1000, what will be the output value stored in variable interest?
- principal ← 1000 // starting money
- rate ← 0.05 // yearly interest rate
- time ← 3 // years
- interest ← principal * rate // yearly interest
- interest ← interest * time // total interest
- interest ← interest + 0 // keep value unchanged
- 150 (correct answer)
- 50
- 155
- 200
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, the variable interest is computed from principal=1000 using rate and time, with an unchanged addition. Choice A is correct because the operations modify interest as: 1000 * 0.05 = 50, 50 * 3 = 150, +0 remains 150 after the program executes. Choice D is incorrect due to a common error of possibly adding the principal to interest again, leading to 200. Encourage students to trace variable changes line by line, and practice identifying common pitfalls such as unnecessary additions or incorrect assumptions about initial values. Reinforce the importance of understanding the order of operations and variable scope.
Question 10
Temperature converter scenario: Refer to the pseudocode. If the input value is 68, what will be the output value stored in variable celsius?
- fahrenheit ← 68 // input temperature
- offset ← 32 // freezing point offset
- difference ← fahrenheit - offset // subtract offset
- celsius ← difference * 5 // multiply by 5
- celsius ← celsius / 9 // divide by 9
- celsius ← celsius + 0 // keep value unchanged
- 20 (correct answer)
- 40
- 18
- 24
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, the variable celsius is computed from fahrenheit=68 through subtraction, multiplication, division, and an unchanged addition. Choice A is correct because the operations modify values as: 68 - 32 = 36, 36 * 5 = 180, 180 / 9 = 20, +0 remains 20 after the program executes. Choice C is incorrect due to a common error of possibly using incorrect conversion factors, leading to 18. Encourage students to trace variable changes line by line, and practice identifying common pitfalls such as order of operations errors or incorrect assumptions about initial values. Reinforce the importance of understanding the order of operations and variable scope.
Question 11
A temperature converter adjusts a reading. If the input value is 50, what will be the output value stored in celsius?
fahrenheit <- 50 // input temperature
celsius <- (fahrenheit - 32) * 5 / 9 // convert
celsius <- celsius + 2 // calibration adjustment
fahrenheit <- fahrenheit + 0 // unchanged input
celsius <- celsius // keep adjusted value
- 12 (correct answer)
- 10
- 14
- 18
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding complex expressions in assignments is crucial for implementing algorithms. In the provided pseudocode, celsius is calculated using the complete conversion formula in one line: (50 - 32) * 5 / 9 = 18 * 5 / 9 = 90 / 9 = 10, then adjusted by adding 2 for calibration. Choice A (12) is correct because the operations correctly calculate: celsius = (50 - 32) * 5 / 9 = 10, then celsius = 10 + 2 = 12. Choice B (10) omits the calibration adjustment, while Choice C (14) might result from an arithmetic error in the conversion. Encourage students to carefully evaluate complex expressions step by step, following order of operations. Practice breaking down compound assignments to verify each calculation stage.
Question 12
A shopping cart adds items and tax. Using the pseudocode below, what is the value of total after executing the code?
itemPrice <- 7 // price per item
quantity <- 4 // number of items
total <- itemPrice * quantity // subtotal
total <- total + 3 // add shipping
total <- total * 1.10 // add 10% tax
quantity <- quantity // unchanged
- 34.1 (correct answer)
- 31.0
- 37.4
- 34.0
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations including multiplication for percentages. Understanding order of operations in financial calculations is crucial for accurate results. In the provided pseudocode, total is calculated as itemPrice * quantity (7 * 4 = 28), then shipping is added (28 + 3 = 31), and finally 10% tax is applied by multiplying by 1.10. Choice A (34.1) is correct because the operations correctly calculate: total = 7 * 4 = 28, total = 28 + 3 = 31, then total = 31 * 1.10 = 34.1. Choice B (31.0) omits the tax multiplication, while Choice C (37.4) might apply tax before adding shipping. Encourage students to trace calculations involving percentages carefully, understanding that multiplying by 1.10 adds 10%. Practice with real-world scenarios involving tax and shipping calculations.
Question 13
A shopping cart updates quantities. Using the pseudocode below, what is the value of total after executing the code?
price <- 12 // dollars per notebook
quantity <- 1 // starting quantity
total <- 0 // running total
total <- total + price * quantity // add 1 notebook
quantity <- quantity + 2 // add two more notebooks
total <- total + price * quantity // add 3 notebooks
- 36
- 48 (correct answer)
- 24
- 60
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how variable updates affect subsequent calculations is crucial for tracking program state. In the provided pseudocode, total starts at 0, then adds 1 notebook (12 * 1 = 12), quantity increases to 3, and then 3 more notebooks are added (12 * 3 = 36). Choice B (48) is correct because the operations correctly modify the variables: total = 0 + 12 = 12, quantity = 1 + 2 = 3, then total = 12 + 36 = 48. Choice A (36) incorrectly calculates only the second addition, while Choice C (24) might result from adding only 2 notebooks in the second step. Encourage students to trace both the quantity variable and how it affects the total calculation. Practice identifying when a variable's value changes and how that affects subsequent uses of that variable.
Question 14
A simple interest calculator uses this pseudocode. What is the value of amount after executing the code?
principal <- 200 // starting money
rate <- 0.05 // yearly interest rate
time <- 3 // years
interest <- principal * rate // one-year interest
interest <- interest * time // total interest
amount <- principal + interest // final amount
- 230 (correct answer)
- 215
- 260
- 205
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for implementing financial calculations. In the provided pseudocode, the interest variable is calculated step by step: first as one year's interest (200 * 0.05 = 10), then multiplied by time (10 * 3 = 30), and finally amount is calculated as principal plus interest. Choice A (230) is correct because the operations correctly calculate: interest = 200 * 0.05 = 10, then interest = 10 * 3 = 30, then amount = 200 + 30 = 230. Choice B (215) might result from calculating only 1.5 years of interest, while Choice C (260) could come from misunderstanding the interest calculation. Encourage students to trace variable changes line by line and understand that each assignment completely replaces the previous value. Practice with real-world scenarios helps reinforce the importance of correct variable tracking.
Question 15
Use this pseudocode: 1 fahrenheit=68; 2 celsius=fahrenheit-32; 3 celsius=celsius*5; 4 celsius=celsius/9; 5 fahrenheit=fahrenheit+9; 6 celsius=celsius+0; What is the value of variable celsius after executing the code?
- 15
- 20 (correct answer)
- 10
- 30
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, fahrenheit starts at 68, then celsius = 68 - 32 = 36, celsius = 36 × 5 = 180, celsius = 180 / 9 = 20, and the final two lines don't change celsius (fahrenheit changes but celsius adds 0). Choice B (20)iscorrectbecausetheoperationscorrectlyconvert68°Fto20°Cusingthestandardformula.ChoiceA(15) is incorrect and might result from a calculation error. Encourage students to trace each operation carefully and note that line 5 modifies fahrenheit (not celsius) and line 6 adds 0 to celsius.
Question 16
Shopping cart scenario: Refer to the pseudocode. What is the value of variable total after executing the code?
- total ← 0 // running total
- price ← 8 // item price
- quantity ← 3 // item quantity
- total ← total + price * quantity // add first item
- quantity ← 2 // update quantity for next item
- total ← total + price * quantity // add second item
- 40 (correct answer)
- 48
- 24
- 56
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, the variable total is initialized to 0 and modified by adding price times quantity twice with updated quantity. Choice A is correct because the operations modify total as: 0 + 83 = 24, then 24 + 82 = 40 after the program executes. Choice C is incorrect due to a common error of forgetting the second addition, leading to only 24. Encourage students to trace variable changes line by line, and practice identifying common pitfalls such as missing updates to variables or incorrect assumptions about initial values. Reinforce the importance of understanding the order of operations and variable scope.
Question 17
Simple interest scenario: Refer to the pseudocode. What is the value of variable amount after executing the code?
- principal ← 500 // starting money
- rate ← 0.06 // yearly interest rate
- time ← 2 // years
- interest ← principal * rate // compute yearly interest
- interest ← interest * time // total interest
- amount ← principal + interest // final amount
- 560 (correct answer)
- 530
- 600
- 1060
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, the variable amount is computed from principal=500 with interest calculated using rate and time. Choice A is correct because the operations modify values as: 500 * 0.06 = 30, 30 * 2 = 60, 500 + 60 = 560 after the program executes. Choice D is incorrect due to a common error of possibly doubling the principal in interest calculation, leading to 1060. Encourage students to trace variable changes line by line, and practice identifying common pitfalls such as misapplying multiplication or incorrect assumptions about initial values. Reinforce the importance of understanding the order of operations and variable scope.
Question 18
Temperature converter scenario: Refer to the pseudocode. What is the value of variable celsius after executing the code?
- fahrenheit ← 50 // input temperature
- difference ← fahrenheit - 32 // subtract offset
- celsius ← difference * 5 // multiply by 5
- celsius ← celsius / 9 // divide by 9
- difference ← difference + 0 // unused update
- celsius ← celsius + 1 // rounding adjustment
- 11 (correct answer)
- 10
- 9
- 12
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, the variable celsius is computed from fahrenheit=50 with difference updated but unused after. Choice A is correct because the operations modify celsius as: 50 - 32 = 18, 18 * 5 = 90, 90 / 9 = 10, 10 + 1 = 11 after the program executes. Choice B is incorrect due to a common error of forgetting the final adjustment, leading to 10. Encourage students to trace variable changes line by line, and practice identifying common pitfalls such as ignoring unused updates or incorrect assumptions about initial values. Reinforce the importance of understanding the order of operations and variable scope.
Question 19
Shopping cart scenario: Refer to the pseudocode. What is the value of variable total after executing the code?
- total ← 0 // running total
- price ← 15 // item price
- quantity ← 1 // first quantity
- total ← total + price * quantity // add first item
- price ← 10 // new item price
- total ← total + price * 2 // add two of second item
- 35 (correct answer)
- 25
- 40
- 30
Explanation: This question tests understanding of variables and assignments in programming (AP Computer Science Principles). Variables store data that can change, and assignments update these values based on operations. Understanding how assignments work is crucial for tracking program state. In the provided pseudocode, the variable total is initialized to 0 and modified by adding different prices and quantities. Choice A is correct because the operations modify total as: 0 + 151 = 15, then 15 + 102 = 35 after the program executes. Choice C is incorrect due to a common error of possibly adding an extra item or miscalculating, leading to 40. Encourage students to trace variable changes line by line, and practice identifying common pitfalls such as confusing variable updates or incorrect assumptions about initial values. Reinforce the importance of understanding the order of operations and variable scope.