Three traces in AP exam notation, all about what a procedure hands back — the thing the multiple-choice section asks about most often once procedures appear.
Work these on paper. There is no computer on exam day.
PROCEDURE procName(p1, p2) define a procedure{ ... RETURN(expression) hand a value back AND leave immediately}
result ← procName(a, b) call it and keep what it returnsprocName(a, b) call it and ignore what it returnsDISPLAY(expression) show it, FOLLOWED BY A SPACE
= is equality. ← is assignment. There is no ==.IF(condition) { } ELSE { } the only two selection formsFOR EACH s IN scores visits every element in order, the way Activity 1.25's exam panel showed. C# has a version too, but this course has not taught it yet; on the exam you only need to read it.
What does this display?
PROCEDURE addTax(price){ RETURN(price + price * 0.1)}
DISPLAY(addTax(100))DISPLAY(addTax(addTax(100)))Careful: the second line calls addTax twice. Work out the inner call first, then use its answer as the outer call's argument.
Build a table of s and what is displayed on each pass.
PROCEDURE band(n){ IF(n ≥ 90) { RETURN("A") } ELSE { IF(n ≥ 80) { RETURN("B") } ELSE { RETURN("C") } }}
scores ← [95, 80, 79]FOR EACH s IN scores{ DISPLAY(band(s))}Then answer this: 80 sits exactly on a boundary. Which branch takes it, and how do you know from the code rather than from guessing?
What does this display?
PROCEDURE mystery(a, b){ IF(a > b) { RETURN(a) } RETURN(b)}
DISPLAY(mystery(3, 9))DISPLAY(mystery(9, 3))DISPLAY(mystery(4, 4))Then answer this: there is no ELSE here, and the procedure still always returns exactly one value. Explain why.
ELSEThis is graded on completion, not accuracy. Show your working — a wrong answer with visible reasoning is worth more to both of us than a right one with none.