A named abstraction that stores a value.
What is a variable?
An ordered sequence of elements.
What is a list?
A value that can only be true or false.
What is a Boolean?
A loop that repeats until a condition becomes true.
What is REPEAT UNTIL?
A named group of instructions that may have parameters.
What is a procedure?
x ← 4
y ← x + 3
x ← 10
DISPLAY(y)
What value is displayed?
What is 7?
nums ← [4, 8, 12]
DISPLAY(nums[1])
What value is displayed?
What is 4?
This programming construct allows a program to choose between different actions based on whether a Boolean expression is true or false.
What is a conditional (IF statement)?
An algorithm uses this construct when it repeats a set of steps either a fixed number of times or until a Boolean condition becomes true.
What is iteration?
What is the argument for the procedure mystery?
PROCEDURE mystery(n)
RETURN(n + n)
DISPLAY(mystery(6))
What is 6?
The operator used to assign a value to a variable in AP pseudocode.
What is ← ?
The position used to access an element in a list.
What is an index?
The logical operator that is true only when both conditions are true.
What is AND?
sum ← 0
REPEAT 3 TIMES
sum ← sum + 2
END REPEAT
DISPLAY(sum)
What is 6?
PROCEDURE mystery(n)
RETURN(n + n)
DISPLAY(mystery(6))
What value is displayed?
What is 12?
a ← 5
b ← a
a ← 10
DISPLAY(b)
What is 5?
nums ← [10, 20, 30]
DISPLAY(nums[2])
What is 20?
IF (x > 10)
DISPLAY("High")
ELSE
DISPLAY("Low")
What is a conditional?
count ← 0
REPEAT 5 TIMES
count ← count + 2
END REPEAT
DISPLAY(count)
What will be displayed by the end of this code?
What is 10?
PROCEDURE greet()
RETURN("Hello")
message ← greet()
DISPLAY(message)
What value is stored in message?
What is "Hello"?
x ← 3
x ← x + 2
x ← x * 4
What is the final value of x?
What is 20?
scores ← [5, 7, 9, 11]
APPEND(scores, 13)
DISPLAY(LENGTH(scores))
What is 5?
x ← 8
IF (x > 5 AND x < 10)
DISPLAY("A")
ELSE
DISPLAY("B")
What is "A"?
x ← 1
REPEAT UNTIL (x > 16)
x ← x * 2
END REPEAT
How many times does the loop body execute?
What is 5 times?
PROCEDURE subtract(a, b)
RETURN(a - b)
DISPLAY(subtract(10, 3))
What value is displayed?
What is 7?