Variables and Assignments FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

Consider:

n ← 100
n ← 25
n ← n + 5

(a) What is n after the second statement? (b) What is n after the third statement? (c) What happened to the value 100?

Question 2 of 5

A student writes the following attempt to swap s and t.

s ← t
t ← s

(a) If s starts as "A" and t as "B", what are both variables after the attempt? (b) Rewrite the swap correctly with a temporary variable. (c) Explain the role of the temporary variable in one sentence.

Question 3 of 5

Trace:

i ← 3
j ← 10
i ← i * 2
j ← j - i
i ← j + i

(a) Give i after the third statement. (b) Give j after the fourth statement. (c) Give the final values of i and j.

Question 4 of 5

A weather station stores yesterday and today temperatures.

(a) Write assignments that set yesterday to 70 and today to 74. (b) Write a correct swap so yesterday holds the former today value and today holds the former yesterday value. (c) Why would today ← yesterday followed by yesterday ← today fail to complete that swap?

Question 5 of 5

Explain assignment order using this segment.

width ← 4
height ← 6
area ← width * height
width ← 10

(a) What is area after the third statement? (b) What is area after the fourth statement if no further assignment to area occurs? (c) What does this example show about when expressions are evaluated relative to later changes of their inputs?